Restrict values of a choice field based on its current status
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2016 09:54 PM
Hello Experts,
I am trying to restrict the values of a choice field based on its current value. I understand we can use "Dependent Field" to restrict the values of based on the values of the other field but what I am trying to do here is little different.
I have a field named "Phase" and it has values viz. Concept, Define, Design, Build, Test, Release, Close.
The default value has been set to Concept. When Phase is set to Concept, it should only show Concept, Define and Close and when it is set to Define it should only show Concept, Define, Build and Close.
I am sure this must have been achieved already by your experts.
Appreciate your help.
Thanks
- Labels:
-
User Interface (UI)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2016 11:43 AM
Wow, I'm not sure why you are willing to write a lot of script to manage these rather than set up a field dependency and go script-less. I thought I was a glutton for scripting punishment.
My recommendation - go with dependent choice fields. Use incident category and subcategory as an example.
Creating New Fields - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2016 12:20 PM
Thanks ctomasi for your reply.
Absolutely, I want to keep things simple and achieve this without complicating it.
As you rightly said the "Dependent" field option works perfectly when the value of one choice field needs to be restricted/displayed based on the value of the other field. However, as I said in my original post what I am trying to achieve is different and I will be glad if you can help me achieve it without having to write script.
I am trying to restrict the values of a field based on the current value of the field. How do we do this efficiently using Dependent field?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2016 01:26 PM
This is the part I'm not clear about.
what I am trying to achieve is different
How is it different? Based on what I read, it sounds like a dependent choice list OOB configuration. What is precluding you from using dependent choice lists?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2016 02:34 PM
May be that's me who is still a rookie in the SN world and underestimating the use of the "Dependent" field.
ctomasi I am trying to restrict the values of a field named Phase based on its own current value.
The field named Phase will have the values viz. Concept, Define, Unassigned, Design,Build, Test, Approved, Production and Closed.
I want to restrict what values are displayed and available for users to select i.e. if the current value of Phase is Concept then users should only be able to see/select Concept, Define and Closed and if the value of Phase is Define then the users should only be able to see/select Concept, Define, Unassigned and Closed.
I see that this works perfectly fine when the values need to be controlled/restricted based on the values of another field but I am struggling to control the values of the same field. I see that it allows you to make a field dependent on itself but I was not able to make it work/make a value appear based for multiple values as it is not working when I provide comma separated values for dependent value like shown below.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2016 02:46 PM
Hi Srirao,
My humblest apologies. I went back and read the thread from the top and realized you are using one field. Dependent fields work with two fields. (E.g. category and subcategory.) I misunderstood the requirements.
Knowing that, I recommend making your own "state table". Something like
Field 1: "Value" (string)
Field 2: "Options" (string)
Populate the value (e.g.) 12 and options 12,13
Make a "universal" client script that uses a GlideAjax call to send the new value to the server and retrieves the "options" from the table that correspond to it and displays it. Now when you need to change the logic, you only change the information in the table and the script stays the same. Best practice: Manage data, not code.
My question then becomes, what's the point? Either way you implement this with client scripts, someone can pick any state with enough selections. If you go through enough combinations (Concept -> Define -> etc.), right? or do you have some options "off limits" to user selection and set via workflow or business rule?
GlideForm (g form) - ServiceNow Wiki
Client Scripts - ServiceNow Wiki
Client Script Best Practices - ServiceNow Wiki