- 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 08:15 AM
I didnt see any errors, just warnings.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2019 11:40 AM
The Catalog Task (out-of-the-box) has reference fields to the Request and the Requested Item.
The Requested Item has reference fields to the Request and the Catalog Item.
So in this setup, I used: sc_task > sc_req_item > sc_cat_item.
Hope that helps in understanding the structure.
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 07:42 AM
Can you share the server side script you are using to set g_scratchpad?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2019 07:49 AM
Sure, this was pre existing code that i just found:
(function() {
g_scratchpad.is_admin = gs.hasRole('admin');
g_scratchpad.is_grpmem = u_isGroupMember(gs.getUserID(), current.assignment_group.sys_id);
g_scratchpad.is_grpmgr = (gs.getUserID() == current.assignment_group.manager);
g_scratchpad.u_cancellable = current.u_cancellable;
g_scratchpad.pending_approvals = false;
g_scratchpad.state = current.state;
g_scratchpad.active = current.active;
gs.info('Hide Closed Cancelled State DEBUG:' + g_scratchpad.cancellable);
var dateStopUsingPending = new GlideDateTime("2014-12-18 00:00:00");
var dateItemCreated = new GlideDateTime(current.request_item.opened_at);
g_scratchpad.use_pending = dateStopUsingPending.compareTo(dateItemCreated) > 0;
var approvals = new GlideRecord('sysapproval_approver');
approvals.addQuery('sysapproval', current.request_item.sys_id);
approvals.addQuery('state', 'requested');
approvals.addQuery('u_ad_hoc', true);
approvals.query();
if (approvals.next()) {
g_scratchpad.pending_approvals = true;
}
})();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2019 07:59 AM
Where is this running? Is it in a business rule? If so what are the conditions it is running under?