- 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-04-2025 10:20 PM
Hi,
Create Input variable and output variables in the Script step of the flow action
- 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 05:59 AM
Hi @Ankur Bawiskar , Thank you, it worked.
I have a requirement to create a Change Task only if the validators(list var from change request) have the ITIL role and it should be automatically assigned to them.
What I tried:
I used a Script Include to check whether users have the ITIL role.
I called this Script Include inside a Script Action.
Based on the Script Action’s output variable, the Main Flow is supposed to create a Change Task and assign it to the filtered users.
My Script include:
My Script action:
I ran a test for the script action by giving the user_ids (i.e) one user id is ITIL and other is Non-ITIL
It's giving the right output values.
Main flow:
When I ran a test for this main flow, the "Create Task" step didn’t get triggered. This is because the output variable is empty and it’s not passing the ITIL users.
I created the change request in the backend and provided the same validators that I used in the Script Action test.
Can you please tell me what went wrong here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2025 06:28 AM
I could not see output variable declared for your Script Step.
-> Did you create it of type Array?
-> the name of that output variable should be filtered_users
-> Then the Action Output will be assigned with the Output variable from Script Step (which you just now created)
-> Once you do then the array will come properly with the output from Script Step
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