How to remove value from a dropdown field?

Erica2
Tera Contributor

Hi everyone

How can we remove "Open" state from One Requested Item (RITM) and keep it for the other RITM?

find_real_file.png

 

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hi,

For one catalog item that the RITM is associated to or a literal RITM, which is an individual record?

If for a specific catalog item that all RITMs could be for...then you can use an onLoad client script such as:

if (g_form.getValue('cat_item') == 'sys_id_of_catalog_item') {
g_form.removeOption('state', 1);
}

There may be more to this, but the basic idea is that you're using "removeOption" to do it.

More information here: https://servicenowguru.com/scripting/client-scripts-scripting/removing-disabling-choice-list-options...

You can use UI Policy as well, as mentioned above, but normally, if there's going to be additional scripting, etc. it's best to use Client Script as it's normally expected there. In either case, it can work, but there's more to think through than just trying to hide a state value.

Keep in mind that some out of box processes may switch it to the "Open" state, by default.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

4 REPLIES 4

Musab Rasheed
Tera Sage
Tera Sage

Hi Erica,

Write UI policy with Condition as 'Item' is 'Name of catalog item' and under script part write following code. Mark my answer as correct if that helps

find_real_file.png

Please hit like and mark my response as correct if that helps
Regards,
Musab

Allen Andreas
Administrator
Administrator

Hi,

For one catalog item that the RITM is associated to or a literal RITM, which is an individual record?

If for a specific catalog item that all RITMs could be for...then you can use an onLoad client script such as:

if (g_form.getValue('cat_item') == 'sys_id_of_catalog_item') {
g_form.removeOption('state', 1);
}

There may be more to this, but the basic idea is that you're using "removeOption" to do it.

More information here: https://servicenowguru.com/scripting/client-scripts-scripting/removing-disabling-choice-list-options...

You can use UI Policy as well, as mentioned above, but normally, if there's going to be additional scripting, etc. it's best to use Client Script as it's normally expected there. In either case, it can work, but there's more to think through than just trying to hide a state value.

Keep in mind that some out of box processes may switch it to the "Open" state, by default.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Allen,

Your suggestion works.  In addition to "Open" state, we also would like to remove "Work in Progress" and other values. Could you please let us know how to you would modify the code. Thanks

Erica2
Tera Contributor

@Allen Andreas 

I figured it out on how to remove additional values from the list.

Thank you