Well, I was able to do it. I'll try to explain how, I suppose you have some general knowledge about data groups and behaviors. If you don't, please let me know.
First of all, we will be using 2 Javascript data groups (one to hide the field, and the other to show it again).
The behavior's "Field to change" is not necesarilly the field we are about to hide or show. In order to be more clear I will state that the field to hide or show is custom_text1 and the field which values we will change is custom_menu1 (A, B and C when custom_text1 hides, and W, X, Y and Z when custom_text1 shows). The triggering will be related to the selection in the system field.
So, we will now create the TextHide Data Group (Javascript):
-Table Name: Custom
-Group Name: TextHide
-Eval Type: Javascript
-Eval Script:
| Code: |
var x=new Array();
x[0]='A';
x[1]='B';
x[2]='C';
var myDiv=document.getElementsByName("custom_text1")[0].parentNode.parentNode;
if (myDiv!=null) {
myDiv.style.display='none';
}
|
And the TextShow Data Group (Javascript too):
-Table Name: Custom
-Group Name: TextShow
-Eval Type: Javascript
-Eval Script:
| Code: |
var x=new Array();
x[0]='W';
x[1]='X';
x[2]='Y';
x[3]='Z';
var myDiv=document.getElementsByName("custom_text1")[0].parentNode.parentNode;
if (myDiv!=null) {
myDiv.style.display='table-row';
}
|
Note that the code specifies the field to hide or to show (custom_text1, hardcoded), and the values to put in the "Field to change" (the name of the field is not hardcoded, and has to be configured in the behavior).
After that, just create the 2 behaviors:
The first one:
PROPERTIES:
-Behavior Name: TextHide (can be any one you like)
-Active: True
-Data Group: TextHide (this is the name of the first data group)
-Field to change: custom_menu1 (as stated in the example)
-Field is enabled: True
RULES: Anyone you like, for example System = 5
The second:
PROPERTIES:
-Behavior Name: TextShow (can be any one you like)
-Active: True
-Data Group: TextShow (this is the name of the second data group)
-Field to change: custom_menu1 (as stated in the example)
-Field is enabled: True
RULES: Anyone you like, for example System = 6
Before going on, be sure to check that these 2 fields (custom_text1 and custom_menu1) are visible in the ticket_create fieldmap configuration. Also check the descriptions associated to the system ids 5 and 6.
After that, go to the New ticket page and toggle the System values through 5 (PC if you are in the default installation) and 6 (Printer if you are in the default installation). You will see the custom_text1 field appear and disappear, and the values of custom_menu1 change from "A, B, C" to "W, X, Y, Z".
I hope the explanation is clear enough and wish you could recreate the example and adapt it to your needs.
Please let me know if there is anything you don't understand and/or if you have any problem.
Regards,
--Claudio