HIde 'Closed Cancelled' state on catalog task when catalog item has the Cancellable checkbox checked

othomas1
Kilo Guru

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?

1 ACCEPTED SOLUTION

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

LinkedIn

View solution in original post

63 REPLIES 63

Yes. Does it alert anything. Keep it as first line.

Nothing at all, no alerts when im on that catalog task page

You are having some issue with other client scripts. You must need to fix those first.

Mark Roethof
Tera Patron
Tera Patron

Could you try to load the exact same Business Rule and Client Script on a Personal Developer Instance, to see if it works there? Because the Client Script message is already not shown, I would think it's something with your instance, conflicting scripting, etc..

Do you also in general experiance that on onLoad Client Scripts messages are not shown?

What if you just add a new onLoad Client Script, with only g_form.addErrorMessage('Does this work?');
Does the message appear then?

Suggesting these ways, because in my opinion there's nothing wrong with the Business Rule and Client Script. Also as mentioned, I also tested these on my PDI, and we already debugged the Business Rule on your side successfully.

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

LinkedIn

Ill try your suggestions now.