Using Javascript in sysparm_query

Abdullah12
Tera Expert

Abdullah12_0-1708602470730.png

I have a requirement that I have use script in sysparm_query in Attachment API. But It is not working as expected(means not returning the correct results).

Abdullah12_1-1708602667952.png

The script include used. In background script it is working fine

Abdullah12_2-1708602769674.png

 

 

1 ACCEPTED SOLUTION

Abdullah12
Tera Expert

As for other people , I want to share this:

Using Javascript in sysparm_query is possible if your script include is client callable and have same function name as the script include.

Abdullah12_0-1708938017036.png

You can use javascript as follows:

Abdullah12_1-1708938126041.png

Results of query:

Abdullah12_2-1708938176522.png

For more information checkout this product documentation regarding scripted Filters :

https://docs.servicenow.com/bundle/washingtondc-platform-user-interface/page/use/using-lists/task/t_...

 

View solution in original post

2 REPLIES 2

palanikumar
Giga Sage

You can't pass the JavaScript this way. Instead create a database view and add your filter condition in the database view. You can call the database view from API.

Otherwise, create a Scripted Rest API and add all your filter within the script.

 

Thank you,

Palani 

Thank you,
Palani

Abdullah12
Tera Expert

As for other people , I want to share this:

Using Javascript in sysparm_query is possible if your script include is client callable and have same function name as the script include.

Abdullah12_0-1708938017036.png

You can use javascript as follows:

Abdullah12_1-1708938126041.png

Results of query:

Abdullah12_2-1708938176522.png

For more information checkout this product documentation regarding scripted Filters :

https://docs.servicenow.com/bundle/washingtondc-platform-user-interface/page/use/using-lists/task/t_...