Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Trying to write my first javascript for script include and it doesn't work.

PJ363182
Tera Contributor

aa.JPG

bb.JPG

cc.JPG

   

Are you able to assist?

 

Thanks

 

1 ACCEPTED SOLUTION

Chaitanya ILCR
Mega Patron

Hi @PJ363182 ,

check the Sandbox enable checkbox it'll work

 

ChaitanyaILCR_2-1741661844357.png

 

ChaitanyaILCR_1-1741661788144.png

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

View solution in original post

9 REPLIES 9

PJ363182
Tera Contributor

I tried with Glide AJAX enabled unticked and it didn't work.

Ankur Bawiskar
Tera Patron
Tera Patron

@PJ363182 

please use classless script include and call like this. ensure it's client callable

javascript: getUsers()

It worked for me

AnkurBawiskar_0-1741663329751.png

 

AnkurBawiskar_1-1741663345484.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar@Medi C 

I think with Xanadu or Later versions the script includes are working on filters only when they are marked as sandbox enabled as true. We can have all kinds of script includes class, classless, client callable or not.

Sandbox Enabled makes it work on filter conditions(works in reports too).

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

@PJ363182 

The 'sandbox enabled' checkbox in ServiceNow's Xanadu release allows you to run scripts within a secure, restricted environment known as a sandbox. This sandbox limits the script's access to certain APIs and resources, enhancing security by preventing potentially harmful operations.

Example Use Case: Imagine you have a script include that processes user input from a client-side form. By enabling the 'sandbox enabled' checkbox, you ensure that this script runs in a controlled environment, reducing the risk of malicious code execution or unintended access to sensitive data.

More details here

Configuring Script sandbox property 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

PJ363182
Tera Contributor

Thanks all. "sandbox enabled" works for me.