Client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 01:26 AM
Hi guys ,
State choice = Closed should be hidden from the form if State = new, for Change Tasks
for that I have written on load client script :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 03:41 AM
script from @Chaitanya ILCR should work
what debugging did you do?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 04:06 AM
as you can see in the SS
option is getting removed but its not getting added when open choice is unselected :
below is the script :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 04:22 AM
Hi @tushar_ghadage ,
for whatever your trying to do you require an onchange client script
update you client script as below
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
if (newValue == '1')
g_form.removeOption('state', '3');
return;
}
if (newValue == '1')
g_form.removeOption('state', '3');
else {
g_form.addOption('state', '3', 'Closed',3)
}
}
but the approach is wrong
with this the purpose of removing closed state on open change is of no use as users can select anyother value to make closed to appear on a open change tasks and select the close directly where the state of change task is still open
they have to save the form first with their option
you have to go with the onload client script here in this scenario(you can refer my first response for that)
but this is what you want update your client script as mentioned
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya