Report filter using callable script include - not executing

thomaskennedy
Tera Guru

I'm trying to use a scripted filter on my report. I want to read only the import set rows belonging to the most recent import set for a given table. So I will pass in the Import Set Row table name as a param and return the sys_id of the most recent import set for that table. (I actually return an array of a single element, for now.) My report will filter the import rows to those where Set.sys_id matches one of these values.

 

So I started by creating a client callable script include, accessible from all scopes, to take the table name as a param.

 

 

var ImportSetDetails = Class.create();
ImportSetDetails.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

	/**
	 * Returns the sys_id of the newest import set created for @tableName
	 */
    getImportSetSysids: function(tableName) {
	// returns an array
    },

    type: 'ImportSetDetails'
});

 

and an ACL:

thomaskennedy_0-1742873564344.png

The ACL has snc_internal.

 

Now the script include works fine. But when I invoke it through a list or through the report filter I get nothing. Adding print statements confirms that the script is not being invoked. The filter expression is:

 

 

javascript: new my_scope.ImportSetDetails().getImportSetSysids("my_scope_vendor_data");

 

 

This must be a permissions problem, but I set up the ACL on the script include. There are a number of posts on this problem, and the all discuss the ACL and making the script include callable. What else can I check?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@thomaskennedy 

gs.info() won't work if you are calling it from report filter condition. it's OOB behavior

Does it work for admins?

are you checking with snc_internal user on report?

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

View solution in original post

3 REPLIES 3

Nishant8
Giga Sage

Hello @thomaskennedy , do you have Standbox check box available in script include, if so, can you enable the same and then try?

Ankur Bawiskar
Tera Patron
Tera Patron

@thomaskennedy 

gs.info() won't work if you are calling it from report filter condition. it's OOB behavior

Does it work for admins?

are you checking with snc_internal user on report?

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

Ankur,

 

You are correct that gs.info will not run when invoked through a filter. I looked over the article and do not see any downside to enabling sandbox behavior in this case, so I checked that box and it works fine now. That will be the plan unless I think of something that does not require the sandbox or an option that does not require JavaScript. Thank you!