- 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-26-2019 10:55 AM
Hi there,
Can you also share the Business Rule with which you've setup the scratchpad?
Also you are mentioning the hide the option (remove), when the checkbox is checked. Your condition is now checking for false, so a unchecked value? Double check if that is correct or that your topic description is just messy.
You could also add some debugging, to see if your script is executing at all and what the scratchpad is containing.
function onLoad() {
g_form.addInfoMessage('==> DEBUG: Client Script is executing, Scratchpad: ' + g_scratchpad.u_cancellable);
if(g_scratchpad.u_cancellable == 'false') {
g_form.addInfoMessage('==> DEBUG: If condition is working');
g_form.removeOption('state', '4');
}
}
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-26-2019 11:04 AM
Hello Mark,
At the moment, there is no business rule in place. I want to hide the option only when the checkbox is clear, not when checked, sorry for that mix up.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2019 11:07 AM
Well how are you generating the scratchpad contents then? If there's no business rule?
So you're setup is never going to work.
Here's some documentation about this for you:
https://docs.servicenow.com/bundle/newyork-application-development/page/script/business-rules/concep...
I will just try something on my PDI.
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-26-2019 11:19 AM
See below, = tested.
---
Create Business Rule:
In the Catalog Task, now you already have the scratchpad available:
Now apply an onLoad Client Script comparable with what you had:
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