- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2019 10:38 AM
Hello everyone,
I thought this one was pretty straightforward so i made a client script, but when a catalog item has the Cancellable checkbox checked, i need the associated catalog tasks to not show the closed cancelled state as a choice in the dropdown, the script below is not working:
function onLoad() {
if(g_scratchpad.u_cancellable == 'false') {
g_form.removeOption('state', '4');
}
}
Can someone spot what my script is missing?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2019 11:16 AM
I was thinking, since the Business Rule and Client Script itself are oke, and the addInfoMessage is simply not displayed, and you don't experience this in general with other Client Scripts:
Do you have other Client Scripts on the same form? Might these be interfering? Have you tried disabling these and retesting to see if the new Business Rule and Client Script are working? If so, then you know there's an issue or conflict with the existing Client Scripts on your form.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2019 09:28 AM
try removing the single quotes around false.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2019 09:33 AM
Also remove the single quotes around 4 in the remove state. State is a integer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2019 09:40 AM
i removed the quotes from both of those, as Mark mentioned the issue seems to be with the client script, the logs on my client script are not displaying, but the log on my business rule displays.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2019 11:13 AM
I got this working in my PDI. Here is the client script. Although a state of 4 is closed incomplete not skipped
function onLoad() {
//Type appropriate comment here, and begin script below
if (g_scratchpad.u_cancellable == 'false') {
//alert ('in if');
g_form.removeOption('state', 4);
}
}
My Business rule has this code in it.
g_scratchpad.u_cancellable = current.request_item.cat_item.u_cancellable;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2019 09:12 AM
Hi,
First thing if your Business Rule is on sc_task, then use
g_scratchpad.u_cancellable = current.request_item.cat_item.u_cancellable; instead of "g_scratchpad.u_cancellable = current.u_cancellable;".
else create new display Br on sc_task with "g_scratchpad.u_cancellable = current.request_item.cat_item.u_cancellable;"
Final one is the Client Script
use this updated client script:
function onLoad() {
if(g_scratchpad.u_cancellable.toString() == 'false') {
g_form.removeOption('state', '4');
}
}
Or,
function onLoad() {
if(g_scratchpad.u_cancellable == false) {
g_form.removeOption('state', '4');
}
}
Regards,
Mandeep