how to solve dependent dropdown field selection problem?

Moderator: crythias

Locked
StefanoBoccanera
Znuny newbie
Posts: 76
Joined: 23 Feb 2011, 15:43
Znuny Version: 3.1.5
Real Name: Stefano Boccanera
Company: I.Conseils (self-employee)
Location: Rome (Italy)

how to solve dependent dropdown field selection problem?

Post by StefanoBoccanera »

hi folks

I have to implement a otrs customer form (i.e. CustomerTicketMessage.dtl) with dynamic dropdown field (F2 for example) content dependent on another dropdown field (F1 for example) selection.
The F2 selection's content would range from 4 to up 40 option. I can't use ticket type or service as selection key due to customer's requirements nor acl due to F2 list's size and its volatily.

My solution according to viewtopic.php?f=60&t=17033) would be:

- Use F1 selection value as switch's value
- Load from external data file the F2 selection content according to the switch's value.
- Select F2 string
- Write the RfC ticket.

But I have some trouble regarding this solution:

1) F2 dynamic field definition. Would be the right definition? Dropdown with a single entry or a text definition, leaving to javascript code/dtl getting the value from a selection?

2) How to about dynamic field key management using a dropdown definition ?

3) I have to modify the CustomerTicketMessage.pm according to dtl modification or I can avoid it?

stefano
Stefano Boccanera

OTRS : 3.1.5
ITSM : 3.1
S.O : RH
RDBMS : Postgres
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: how to solve dependent dropdown field selection problem?

Post by crythias »

viewtopic.php?f=53&t=16009#p64539
StefanoBoccanera wrote:Would be the right definition? Dropdown with a single entry or a text definition, leaving to javascript code/dtl getting the value from a selection?
If you want a drop down, it's going to be easier to populate a drop down than (weirdly) convert a text input to a dropdown.
StefanoBoccanera wrote:2) How to about dynamic field key management using a dropdown definition ?
What does this mean in English?
StefanoBoccanera wrote:3) I have to modify the CustomerTicketMessage.pm according to dtl modification or I can avoid it?
You *have* to either modify CustomerTicketMessage.pm to apply the javascript for dependent fields (that is, explicitly on the master field -- the field that, if you change it, another field is reflected in this change.)
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
StefanoBoccanera
Znuny newbie
Posts: 76
Joined: 23 Feb 2011, 15:43
Znuny Version: 3.1.5
Real Name: Stefano Boccanera
Company: I.Conseils (self-employee)
Location: Rome (Italy)

Re: how to solve dependent dropdown field selection problem?

Post by StefanoBoccanera »

Hy crythias

first of all sorry for my bad english, may be something of my note was obscure.

From you reply I understood following

a) I have to declare a dropdown field without any entry
b) in dtl I have to populate the dropdown field including a key value and a selection value (that answer to my bad-written question)
c) I have to modify the CustomerTicketMessage.pm. Until now I managed every needed change into DTL and in my, so after I read the file I didn't identify the right section.

Can you help me ?

best regards

stefano

p.s.

sorry for every duplicate message, but I didn't remebere about 'approval' message management, so I tought about browser error.
Stefano Boccanera

OTRS : 3.1.5
ITSM : 3.1
S.O : RH
RDBMS : Postgres
StefanoBoccanera
Znuny newbie
Posts: 76
Joined: 23 Feb 2011, 15:43
Znuny Version: 3.1.5
Real Name: Stefano Boccanera
Company: I.Conseils (self-employee)
Location: Rome (Italy)

Re: how to solve dependent dropdown field selection problem?

Post by StefanoBoccanera »

Crythias
I would explain my needs.

First of all I have to say I can't use any standard approach like service etc. due to client's constraints, that because your suggestion it's very appealed for me.

I have two dynamic field (let me say A and B).
Field A is a dropdown filed with some entries like

Infrastructure
Application Category A
Application Category B
AIX Department Systems
Linux Department System

After customer selects one of choice in field A (filed A entries are pre-defined into field definition), field B (dropdown) will be populated with a dinamic list of selection entry, a different list for each entry of field A.

My strategy is :

Modify CustomerTicketMessage.dtl (maybe also AgentTicketPhone.dtl) as follow:

1) Field A - pass the key value linked to the selected entry as 'on change' attribute for field B
2) Field B - insert the jscript from your suggestion, calling a .pl module and passing the key value from step 1. This value will be used from the .pl module as a switch key to identify the right file to load.
3) Load the key-value pair form the file and output the right selection list.

As stated into a previous reply, I have some doubt about how to modify the CustomerTicketMessage.pm. Until now I customized some .pm modules but always without a strong interaction with dtl files.

hope I made a step ahead to explain my need.

best regards

stefano
Stefano Boccanera

OTRS : 3.1.5
ITSM : 3.1
S.O : RH
RDBMS : Postgres
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: how to solve dependent dropdown field selection problem?

Post by crythias »

I made a mistake. I meant to say ... you have to modify CustomerTicketMessage.dtl, not .pm
StefanoBoccanera wrote:1) Field A - pass the key value linked to the selected entry as 'on change' attribute for field B
Yes, that's what's intended by ...

Code: Select all

    <script type="text/javascript">
        $.get('extdata.pl', function(data) {
           $('#myselect').append(data);
    });
    </script>
This is a population "on load". To do dependent fields, you'd use something like
http://api.jquery.com/jQuery.get/
<script type="text/javascript">//<![CDATA[
$('#fieldname').bind('change', function (data) {
// make sure the ticket is not yet created on type change
$.ajax({
type: 'get',
url: 'extdata.pl',
data: data,
success: cb
});
});
//]]></script>
You may need to find out more about jQuery and passing variables, values, etc. The link in my "Help" should generally work if the dependent data (Category B) is filtered by ACL based upon the choice of Category A. If you need dependent, variable, external data, it is probably currently outside the scope of what I can provide at this time.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Locked