Syntax to return multiple sys_ids to report

e_wilber
Tera Guru

I have a simple report that is using a script include to get a list of sys ids to return. It is only returning one record of the three that show up when I run the same condition in list view.

The script include is running this query:

ctask.addQuery("change_request.start_date>=javascript:gs.dateGenerate('2018-06-19','00:00:00')");
ctask.addQuery("change_request.start_date>=javascript:gs.dateGenerate('2018-06-21','23:59:59')");

In the report, it's only returning one change task. When I use the condition builder in list view on the change task for the exact same dates and times, it returns 3 change tasks.

I am thinking it's how I'm trying to return the values to the report. I've tried:

SysID is | return foundChangeTasks.join(',^OR');
SysID is one of | return foundChangeTasks.join(',^OR');
SysID is one of | return foundChangeTasks.join('\n');

Since I'm returning a list of sys_ids, am I returning it incorrectly?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Wilber,

you can return an array as well from the script include. how are you calling the script include in the filter condition. i assume it should be like this

sys_id IN javascript: new ScriptInclude().function();

function is returning something like this

var arr = [];

this array contains list of sys ids based on your while loop

return arr;

Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Wilber,

you can return an array as well from the script include. how are you calling the script include in the filter condition. i assume it should be like this

sys_id IN javascript: new ScriptInclude().function();

function is returning something like this

var arr = [];

this array contains list of sys ids based on your while loop

return arr;

Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

You were right - returning the array without doing a join fixed the problem.

Thank you