Dynamic fields trees?

Moderator: crythias

Post Reply
Dolm
Znuny newbie
Posts: 8
Joined: 26 Nov 2011, 06:38
Znuny Version: 3.1.0

Dynamic fields trees?

Post by Dolm »

Is it possible to make dynamic dropdowns that are trees? What I mean is, values in the first drop-down determine whats available in the next..is this possible?
---------------------------------------------------------------------
OTRS 3.1.0 , Ubuntu Server 11.04, Apache2, MySQL
jojo
Znuny guru
Posts: 15019
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Dynamic fields trees?

Post by jojo »

no, as the dynamic fields are a backend functionality.
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
Dolm
Znuny newbie
Posts: 8
Joined: 26 Nov 2011, 06:38
Znuny Version: 3.1.0

Re: Dynamic fields trees?

Post by Dolm »

Why are they called dynamic?
---------------------------------------------------------------------
OTRS 3.1.0 , Ubuntu Server 11.04, Apache2, MySQL
jojo
Znuny guru
Posts: 15019
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Dynamic fields trees?

Post by jojo »

because they allow dynamiv usage of fields, like activating and deactivating them. Also you are not bound to a certain number, they are unlimeted
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
ncallahan
Znuny newbie
Posts: 2
Joined: 23 Jan 2012, 12:24
Znuny Version: 3.1 beta
Real Name: Nathan Callahan
Company: Squiz

Re: Dynamic fields trees?

Post by ncallahan »

If you're willing to structure and de-normalise your data a little, I have a solution to this using javascript to perform the cascade on the front-end. After spending quite a while, trying in vain to get it to work using ACLs (what is the point of the "Possible" ACLs for Dynamic Fields? They don't seem to do anything), I decided to use a similar method to that which I used in OTRS 3.0.

It may be that this doesn't work in Internet Explorer. Since none of our Agents use IE, I'm not really concerned for my own application.

If you structure your data so that all of the allowed keys for the second level start with the string for the first value, then this little piece of javascript should help.
eg. If you have:
TicketFreeText1
  • Key: A Value: Something
  • Key: B Value: Something Else
  • Key: C Value: Last
TicketFreeText2
  • Key: AA — Value: This will appear as an option when "Something" is selected
  • Key: AB — Value: This will also appear as an option when "Something" is selected
  • Key: BA — Value: This will appear as an option when "Something Else" is selected
  • Key: BB — Value: This will also appear as an option when "Something Else" is selected
  • Key: CA — Value: This will appear as an option when "Last" is selected

Code: Select all

jQuery.fn.dynamicFieldTree = function (master) {
	return this.each(function() {
		var slave = this;
		$(slave).find('option').each(function(i,o) {
			if ($(master).attr('value')=='' && ($(o).attr('value') != '') || ($(o).attr('value').indexOf($(master).attr('value')) != 0)) {
				$(o).remove();
			}
		});
		$(slave).bind('DOMNodeInserted', function(e) {
			if (e.target.value.indexOf($(master).attr('value')) != 0) {
				$(e.target).remove();
			}
		});
	});
}

$(function() {
        $('#DynamicField_TicketFreeText2').dynamicFieldTree($('#DynamicField_TicketFreeText1'));
});

Post Reply