The ‘Field & Form Rules’ is a great new feature for Request templates in ManageEngine ServiceDesk Plus. The feature allows for the creation of dynamic forms that change in response to selection of field values and content.
 
 
 
 
 
FieldForm1
 
 
 
 
 
Whilst there are standard actions that can be defined for a Field and Form Rule, such as Enable / Show / Hide / Mandate fields, there is also an ‘Action’ option to ‘Execute Script’ which allows for even further customisation.
 
 
 
 
 
 
FieldForm2
 
 
 
 
 
 
 
 
Now Zoho have a couple of sample scripts, one of which a number of customers have wanted to use, namely the ‘Dependency Example’. However, the example given involves three related fields and is not immediately clear regarding its operation even with the details provided in the on-line help. Generally we’re looking to define two related fields rather than three so I thought I’d add a few notes to assist anyone looking to use this feature.
 
To test a dependency script create a new test Incident template create a couple of ‘Pick List’ custom fields on this template, e.g. First Pick List with options Option 1, Option 2 and Option 3 and Second Pick List with options Option A, Option B and Option C :
 
 
 
FieldForm3
FieldForm4
 
 
 
 
 
 
Next create a new Field and Form Rule for an ‘On Form Load’ action with an ‘Action’ of ‘Execute Script’ and click the option to ‘Write Script’ (no condition is necessary on the rule). In the pop-up editor paste the following script code and save.
var dependencyObj= {
    “FIELDS” :[“First Pick List”,”Second Pick List”],
    “VALUES”:{
        “Option 1”:[“Option A”,”Option B”,”Option C”],
        “Option 2”:[“Option A”,”Option B”],
        “Option 3”:[“Option C”]
    }
};
$CS.setFieldDependency(dependencyObj);
 
Next enter a request using this test Incident Template and check your dependency fields, you should see that the values of the ‘Second Pick List’ field will change dependent on the value of the ‘First Pick List’ field, in the example choosing ‘Option 1’ gives the two selections ‘Option A & Option B’ rather than all three:
 
 
FieldForm5
 
 
 
Cool huh? 
 
Few things to note:
  • In the script use the unique alias name or label you used to define the field (ServiceDesk Plus has it’s own internal naming convention for these fields).
  • Make sure you define all the options needed in the dependent field(s), in our example the ‘Second Pick List’ field.
  • It should be noted that these are scripts saved in the rule itself. They are not external scripts such as PowerShell or Python. The script should be valid JavaScript code in order to execute. 
  • Need three related fields? Try the format of the extended script below using a third dependent pick list (don’t forget to create the custom field and add it to your test Incident template):

 

var dependencyObj= {
    “FIELDS” :[“First Pick List”,”Second Pick List”,”Third Pick List”],
    “VALUES”:{
        “Option 1”:{
             “Option A”:[“Option i”,”Option iv”],
             “Option B”:[“Option iii”],
             “Option C”:[“Option i”]
        },
        “Option 2”:{
             “Option A”:[“Option ii”,”Option iii”],
             “Option B”:[“Option i”]
       },
        “Option 3”: {}       /* no sub selections
    }
};
$CS.setFieldDependency(dependencyObj);
 
Enjoy!
This article is relevant to:
Service Desk

You may be interested in these other recent articles

Latest Updates for ManageEngine ServiceDesk Plus Cloud

12 November 2024

Discover the latest ServiceDesk Plus Cloud updates, including new features, fixes, and enhancements.

Read more

Latest Updates for ManageEngine ADSelfService Plus

11 November 2024

The current build release information for ManageEngine ADSelfService Plus is summarised below. Scroll down for more information. You can download the latest service packs here.…

Read more

Latest Updates for ManageEngine ServiceDesk Plus On-Premise

29 October 2024

Discover the latest ServiceDesk Plus updates, including new features, fixes, and enhancements.

Read more

Latest Updates for ManageEngine Endpoint Central

16 October 2024

Discover the latest Endpoint Central updates, including new features, fixes, and enhancements.

Read more

ManageEngine ADManager Plus Build Release Information

14 October 2024

Summary details of the current build release information for ManageEngine ADManager Plus. Scroll the above to view more release details. Download the latest service packs…

Read more