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

ManageEngine Endpoint Central (formerly Desktop Central) On-Premise Build Release Information

18 April 2024

Summary details of the current Build Release information for ManageEngine Endpoint Central. Note: Desktop Central changing its name to Endpoint Central will not affect the…

Read more

ManageEngine ADSelfService Plus Build Release Information

16 April 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

ManageEngine ADManager Plus Build Release Information

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

ManageEngine ServiceDesk Plus Cloud Build Release Information

11 April 2024

Summary details of the current Build Release information for ManageEngine ServiceDesk Plus Cloud Edition. All upgrades are performed by the Zoho Cloud team. Should you…

Read more

ManageEngine Analytics Plus Build Release Information

4 April 2024

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

Read more