- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 04:10 AM - edited 02-07-2024 04:14 AM
Hi,
So recently I had a requirement to add new choices to the 'Resolution Code' field on the incident form. The new choices had to be visible to the user but the older choices had to be hidden from the user but still be available for automations.
I was able to achieve this functionality by
1)creating the new choices in the sys_choice_list table
2) Using an OnLoad client script to hide the previous choices for the user but they are available for automations. Here is the client script below
function onLoad() {
//Type appropriate comment here, and begin script below
g_form.removeOption('close_code',"Solved (Work Around)");
g_form.removeOption('close_code',"Solved (Permanently)");
g_form.removeOption('close_code',"Solved Remotely (Work Around)");
}
However, one of the choices 'Alert Cleared No Action Taken' was in the list of new choices to be created. An already existing choice called 'Alert cleared no action taken' was already there (only capitalization change). Instead of amending the previous choice for the capitalization, I just created a new one instead.
The requirements changed and what they want now is that the choice 'Alert cleared no action taken' choice should be user selectable when 'Channel=Automation'
I was able to achieve that through using a UI policy. Where I set 'When to apply: channel=automation' and in the script I have
Execute if true:
function onCondition() {
g_form.addOption('close_code',"Alert Cleared No Action Taken");
}
Execute if false:
function onCondition() {
g_form.removeOption('close_code',"Alert Cleared No Action Taken");
}
The UI policy seems to be working fine however, when I select the Channel=Automation, the 'Resolution code' field displays 'Alert Cleared No Action Taken" and a blank value as shown in picture below
When the blank option is selected and the record saved, then in the notes it says 'Resolution Code: Alert cleared no action take' it shows the lower case option as being selected.
I deleted this lower case option and left just the capitalized option and that is still happening. I deleted the capitalized option too and created a new option with the capitalization, but the issue still persists of the blank option showing, however, now the blank option is the capitalized option. What can I do to fix it? Why is this happening?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 04:26 AM
@snow_beginner Could you please update the code Execute if true to as follows.
function onCondition() {
g_form.addOption('close_code',"Alert Cleared No Action Taken","Alert Cleared No Action Taken");
}
The las parameter refers to the display value on the select box. Here is the link of method for reference https://developer.servicenow.com/dev.do#!/reference/api/vancouver/client/c_GlideFormAPI#r_GF-AddOpti...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 04:26 AM
@snow_beginner Could you please update the code Execute if true to as follows.
function onCondition() {
g_form.addOption('close_code',"Alert Cleared No Action Taken","Alert Cleared No Action Taken");
}
The las parameter refers to the display value on the select box. Here is the link of method for reference https://developer.servicenow.com/dev.do#!/reference/api/vancouver/client/c_GlideFormAPI#r_GF-AddOpti...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 04:35 AM
Thanks so much! That has worked.