Catalog Client script not working

swesarjann
Tera Contributor

Hi everyone, I have created a new catalog client script. However, it does not work even though I am just logging in the console. I have checked and not other UI policy runs to counteract this. I will attach the script here.

 

ps. it works once if I trigger it multiple times

3 ACCEPTED SOLUTIONS

@swesarjann try to add an alert in the client script and run it in incognito window by changed the requested for field. Hopefully it will work as sometimes client script throw issues due to browser caching. 

View solution in original post

Vishal Birajdar
Giga Sage

Hi @swesarjann 

 

Can you please let us know where you are checking the logs...??

also can you put some alert() in your script to check it.

 

alert('My message');  //something like this

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

View solution in original post

That's great...!!

Console logs also works...You have to check that in browser console actually like below :

This is my script :

VishalBirajdar_1-1705654544883.png

 

VishalBirajdar_0-1705654502993.png

 

 

To check browser console >> Right click on page >> Select 'Inspect' 

 

VishalBirajdar_2-1705654681321.png

 

 

 

 

 

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

View solution in original post

12 REPLIES 12

swesarjann
Tera Contributor

The ending brackets for the onchange function is present, I just couldn`t show in the screenshot

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

Since you are mentioning it does work when triggered multiple times... can you describe exactly your starting point and how you are testing?

For example, perhaps requested_for is filled onload already? Do share such information as it might be very important to know.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Yes, do I test by triggering the script and changing the requested for variable, if I test multiple times I can get it to log to the console once.

 

The variable also has the default value of the logged in user. I tried testing without the default value but it still doesn`t trigger

Sandeep Rajput
Tera Patron
Tera Patron

@swesarjann This is an onChange script and should run on change of requested_for variable. Are you testing it by updating the values on requested for field? Also, the log will be shown on Browser console.