[SOLVED] A dynamic field dependent on another one

Moderator: crythias

Locked
girishmungra
Znuny newbie
Posts: 59
Joined: 24 Jul 2012, 18:20
Znuny Version: 3.1.7
Real Name: Girish Mungra

[SOLVED] A dynamic field dependent on another one

Post by girishmungra »

Hi,
I wish to have tickets categorized by agents before they are closed.
I have thus created 2 dynamic fields (dropbox): Category and Sub Category, to appear in the AgentTicketClose screen.
Now, sub category should be dependent on the value selected in Category.
I tried to achieve this using ACL but the SubCategory field doesn't refresh with the specific values I want to see.
Here's my ACL:

$Self->{TicketAcl}->{'300-Restrict Classification list-ACL'} = {
Properties => {
Ticket => {
Queue => ['Support'],
}
},
Possible => {
Ticket => {
DynamicField_Category => ['Hardware','Software'],
}
}
};



$Self->{TicketAcl}->{'310-Restrict Classification list-ACL'} = {
Properties => {
DynamicField => {
DynamicField_Category => ['Software'],
}
},
Possible => {
Ticket => {
DynamicField_Subcategory => ['Windows'],
}
}
};

Thanks for help.
Last edited by girishmungra on 04 Mar 2013, 08:21, edited 1 time in total.
OTRS 3.1.7 on Linux RedHat with MySQL database connected to an Active Directory for Agents and Customers.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: A dynamic field dependent on another one in the same pag

Post by crythias »

girishmungra wrote:I have thus created 2 dynamic fields (dropbox): Category and Sub Category, to appear in the AgentTicketClose screen.
Now, sub category should be dependent on the value selected in Category.
This sounds like a bothersome thing to do...
Is it that much more difficult to put a list of Category-Subcategory versus what you want?
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
girishmungra
Znuny newbie
Posts: 59
Joined: 24 Jul 2012, 18:20
Znuny Version: 3.1.7
Real Name: Girish Mungra

Re: A dynamic field dependent on another one in the same pag

Post by girishmungra »

Am afraid am not getting your point here.

I have 2 dynamic fields (dropboxes).
1.Category
2.Sub-Category.

The way I want this to work is:
I select 'Hardware' from Category and Sub-Category is populated automatically with values related to Hardware e.g PC, Printer, Scanner, laptop, etc
And if I choose 'Software' in Category, Sub-Category field gets a new list of applications used.
OTRS 3.1.7 on Linux RedHat with MySQL database connected to an Active Directory for Agents and Customers.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: A dynamic field dependent on another one in the same pag

Post by crythias »

How many total items will you have listed in category 2?
Are the items in subcategory column 2 unique enough that you can obviously tell what category they are?
Why isn't category 1 a queue and category 2 a service?
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
girishmungra
Znuny newbie
Posts: 59
Joined: 24 Jul 2012, 18:20
Znuny Version: 3.1.7
Real Name: Girish Mungra

Re: A dynamic field dependent on another one in the same pag

Post by girishmungra »

thanks for prompt reply.

We have around 20 teams and each is represented by a queue.
Each team can look after up to 4 systems (category) and each system can have up to 10 modules (Subcategory).

The 'category' dynamic field can be restricted per queue using ACL ( Thank god else it would have displayed 80 categories at once).
What I don't want is the subcategory to display 40 items for this same queue. hence my need to have it dependent on the 'Category' field.
OTRS 3.1.7 on Linux RedHat with MySQL database connected to an Active Directory for Agents and Customers.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: A dynamic field dependent on another one in the same pag

Post by crythias »

First, an apology, because I hadn't researched this hard enough, and second, a fix.

You are exactly doing the right thing, but what you're missing is the js bind on the original Category field.
Note what's in the .dtl for other dependent fields.

What's used for acl check on change of queue:

Code: Select all

<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
    $('#Dest').bind('change', function (Event) {
        // make sure the ticket is not yet created on queue change
        $('input#Expand').val(1);
        Core.Form.Validate.DisableValidation($(this).closest('form'));
        $(this).closest('form').submit();
    });
//]]></script>
<!--dtl:js_on_document_complete-->
This means you probably should include the similar code (replacing #Dest for the id of the Category Field) within the <!-- dtl:blockDynamicField_Category --> that you might manually enable or else drop the script into the bottom of the dtl in dtl:js_on_document_complete. (I would recommend manually enabling the field in the .dtl instead of via sysconfig.)

Edit: this is in CustomerTicketMessage.dtl

In AgentTicketActionCommon.dtl, it shows like:

Code: Select all

<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
    $('#NewResponsibleID').bind('change', function (Event) {
        Core.AJAX.FormUpdate($('#Compose'), 'AJAXUpdate', 'NewResponsibleID', [ 'TypeID', 'ServiceID', 'SLAID', 'NewOwnerID', 'OldOwnerID', 'NewStateID', 'NewPriorityID', $Data{"DynamicFieldNamesStrg"} ]);
    });
//]]></script>
<!--dtl:js_on_document_complete-->
So you might want to follow the same information of a sample type, including what field you'd like to refresh based upon the change in the original.
for the last entry, you'll want to change "NewResponsibleID" for your Category field id in a couple of places. You may want to consider whether you wish to trust $Data{"DynamicFieldNamesStrg"} for your specific needs or just manually include the id for SubCategory.

Look for other similar changes depending on what .dtl applies to the screen you wish this to function.
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
girishmungra
Znuny newbie
Posts: 59
Joined: 24 Jul 2012, 18:20
Znuny Version: 3.1.7
Real Name: Girish Mungra

Solved A dynamic field dependent on another one in the same

Post by girishmungra »

Great! Thanks a lot. It worked.
OTRS 3.1.7 on Linux RedHat with MySQL database connected to an Active Directory for Agents and Customers.
Antimidas
Znuny newbie
Posts: 3
Joined: 11 Mar 2013, 18:48
Znuny Version: 3.2.2
Real Name: Marty Hillman
Company: Equus

Re: [SOLVED] A dynamic field dependent on another one

Post by Antimidas »

You mention modifying the .dtl files. Can you be more specific as to where those are located?

I have a similar thing I am trying to do. User selects a type and sub-type. Based on those combinations, there are 26 possible queues that the ticket can be placed in.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: [SOLVED] A dynamic field dependent on another one

Post by crythias »

Antimidas wrote:User selects a type and sub-type.
they should directly choose the queue in this case.
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
Antimidas
Znuny newbie
Posts: 3
Joined: 11 Mar 2013, 18:48
Znuny Version: 3.2.2
Real Name: Marty Hillman
Company: Equus

Re: [SOLVED] A dynamic field dependent on another one

Post by Antimidas »

Ok. I admit to being a doofus. I see the two DTL files that need to be modified. To make sure these are not overwritten with upgrades, I created a new folder as per the Admin manual in Chapter 14 and only copied the two DTL files to it.

Now I just have to throw caution to the wind and try it in development. Thank God I don't yet have to do this on a production site.

For the record, here is the abbreviated hierarchy. Tier 3 is to be displayed based on the combination of TIer 1 and Tier 2. There is no overlap.

MIS
........Problem
................Email
................Printing
................ ...
........Request
................Website
................Login or Access Privileges
................Other
Product Engineering
........Problem
................Software
................Hardware
................ ...
........Request
................System testing
................Component testing
................ ...
kvytla
Znuny newbie
Posts: 22
Joined: 22 Aug 2012, 20:20
Znuny Version: OTRS 4.0.9

Re: [SOLVED] A dynamic field dependent on another one

Post by kvytla »

Hey I am trying to fix the same thing here. I have configured two dynamic fields in a process ticket (New Hire On boarding) as mentioned below.

Dynamic field 1
Hardware Profile :

Values for Dynamic Value 1
Engineers & Leads
Managers
Directors & above

Dynamic field 2
Hardware Details

Values for Dynamic Field 2
i5+4gb+256gb Sata
i5+8gb+256gb
i5+8gb+256gb SSD

I need to change the values in dynamic field 2 based on the Dynamic field 1. Can you please help on this configuration.
smuwanga
Znuny newbie
Posts: 27
Joined: 31 Dec 2014, 10:57
Znuny Version: 5.0.22
Real Name: Simon Peter Muwanga
Company: UgandaSoft
Contact:

Re: [SOLVED] A dynamic field dependent on another one

Post by smuwanga »

Hello,

ACLs will do the trick. They've worked for me.
viewtopic.php?f=53&t=29307&hilit=How+ca ... mic+fields
Smiith
Znuny newbie
Posts: 19
Joined: 22 Jul 2015, 10:49
Znuny Version: OTRS 4
Real Name: Muhammad Hassanine Haddad
Company: CIMEF

Re: [SOLVED] A dynamic field dependent on another one

Post by Smiith »

smuwanga wrote:Hello,

ACLs will do the trick. They've worked for me.
viewtopic.php?f=53&t=29307&hilit=How+ca ... mic+fields
Hello !

Can you help me please, i'm newbie.
After editing the file Config.pm, i will find the fields automatically added in the ticket plateform ? or i must add dynamic fields ?

Thanks
Locked