- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2014 10:03 AM
Hi guys,
I have created a UI policy to hide (stop a value from being selected) on a field called 'Subtype' e.g. value 'Minor' when the value of 'Domain' field is e.g. 'Deacons' - while this works if the Domain chosen initially is 'Deacons' if it is then changed, the 'Minor' Subtype value is still unselectable (when it should be selectable). Likewise if I choose another Domain initially and set the Subtype as 'Minor' I can then change the Domain value to 'Deacons' - meaning the Subtype value which should not be selectable is!
I think this is because I have it onLoad in the UI Policy - in which case I need it more dynamic, i.e. whenever the value of Domain field changes, do I therefore need a client script instead?
Another option would be to force the value of Subtype to always be 'Standard' when the Domain is 'Deacons' but I'm unsure what is easier.
Any/all help much appreciated as always.
Cheers,
Daniel
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2014 04:46 AM
whatever value you want to set use the below line in 'execute if true' and 'execute if false' section,
g_form.setValue('subtypeVariableName','whateverValueNeeded');
place this as the last line in the corresponding sections

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2015 11:40 PM
It should be g_form.setValue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2014 03:31 AM
Not sure if you are aware of this, but you can actually make the choice list dependent on Domain and simply add the fields based on Domain. While this may take more time than putting an onChange script, it will be more stable and execute quicker.
http://wiki.servicenow.com/index.php?title=Creating_New_Fields#Making_a_Field_Dependent
Customizing Choice Lists - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2014 04:58 AM
Agree with Harikrishnan on this. UI policies and Client Scripts will be very inefficient and full of issues.
Dependant fields (like Category and Sub Category on Incident) is the only way to go on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2014 05:23 AM
Andrew please can you elaborate why it's inefficient and full of issues?
Via use of UI Policy and script (within the UI Policy) it's working exactly as hoped and is instant at updating when a different Domain is chosen.
In terms of the Dependent fields, two other fields are actually coming into play here not just one: Domain and Type.
Cheers,
Daniel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2014 05:32 AM
As you have stated in one of your replies:
"All Domains should see all Types (i.e. Planned, Routine, Emergency).
Subtypes are dependent on Types. (i.e. Standard and Minor for Planned, 20+ options for Routine and 5 for Emergency)."
There are multiple combinations here, meaning the only true way to capture all of the possibilities of field changes etc is to use dependant values so that the whole list is refreshed from the server after a change to the first field. Otherwise you will need a load of addOption and removeOption scripts that have to be constantly synced with the choice list values. What happens if another developer changes the choice lists and doesn't thing to update your UI Policies/Client Scripts?
Either way the Best Practice way to achieve this is to use dependant values. There maybe other ways that work, but thats why we call it Best Practice 🙂