- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2025 02:27 PM
I'm working on a Flow Designer Action where I need to filter users based on the itil role using a Script Include and return a list of their sys_ids via Script step output variable.
Script Include (GetITILValidators):
var GetITILValidators = Class.create();
GetITILValidators.prototype = {
initialize: function() {},
getITILUsers: function(validatorsList) {
var itilUsers = [];
if (!validatorsList)
return itilUsers;
var userIds = validatorsList.split(',');
for (var i = 0; i < userIds.length; i++) {
var user = new GlideRecord('sys_user');
if (user.get(userIds[i]) && user.roles.toString().includes('itil')) {
itilUsers.push(user.sys_id.toString());
}
}
return itilUsers;
},
type: 'GetITILValidators'
};
Flow Designer Action:
Input: user_ids (Type: String, Mandatory)
Output: filtered_users (Type: Array.String)
Script Step:
What adjustment do I need to make in the code or Flow Action setup to fix this?
Any help would be appreciated!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2025 10:32 PM
did you create an input and output variable under the Script Step?
You need to create it with the correct type based on what script include returns and based on what the action is accepting as input.
Then map the Action Output with Script Step Output
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2025 06:43 AM
@Ankur Bawiskar Thank you for your response, it's already declared in the Script action as an array.string
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2025 07:06 AM
Click on Exit Edit mode and did you map the output of action with Script Step output?
Like this I mapped
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2025 07:23 AM
This worked, Now i can see the filtered users output in the test script action results.
Unfortunately when i ran a test with the main flow, this is returning empty value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2025 07:31 PM
are you not able to iterate that output using For Each?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2025 05:18 AM
Yes, it's because filtered_users output was returning an empty array and the for each step didn't iterate over any items