Removal users through catalog Request
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi Team,
I have created a catalog item with two variables:
Entities (List Collector)
Users Removal (List Collector)
Requirement:
Based on the selected entities and users, the selected users should be removed from the respective Entity Stakeholder records (sn_grc_entity_stakeholder) from the user field.
Current Flow Design:
Trigger: Service Catalog Requested Item
Lookup Entity Stakeholder records based on:
Entity is one of selected entities
For Each Entity Stakeholder record
Created a custom Flow Action with inputs:
Current Users
Users To Remove
In the Action script, comparing current users and removing selected users, then returning updated users output.
Finally updating the Entity Stakeholder user field with updated users output.
Action Script:
(function execute(inputs, outputs) {
var currentUsers = inputs.current_users.split(',');
var removeUsers = inputs.users_to_remove.split(',');
var updatedUsers = [];
for (var i = 0; i < currentUsers.length; i++) {
var user = currentUsers[i].trim();
if (removeUsers.indexOf(user) == -1) {
updatedUsers.push(user);
}
}
outputs.updated_users = updatedUsers.join(',');
})(inputs, outputs);Issue:
When testing the Action manually with sample values, it works correctly.
Example:
Current Users:
user1,user2,user3
Users To Remove:
user2
Output:
user1,user3
But during actual Flow execution:
updated_users output is coming empty
Sometimes debug output shows values like:
[object GlideRecord]
instead of comma-separated sys_ids
Because of this, the user field is getting updated as empty.
I already verified:
Action inputs are configured as String type
Passing:
For Each ā Entity Stakeholder ā User List
Catalog Variables ā Users Removal
Both Entity Stakeholder records and User List values are present correctly
Could someone please suggest the best approach to handle glide list/user list values in Flow Designer for this scenario?
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
27m ago
share how you are calling this from your flow and how are you sending the input?
š” If my response helped, please mark it as correct ā and close the thread šā this helps future readers find the solution faster! š
Ankur
⨠Certified Technical Architect || ⨠10x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Update action script with this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
@ziarahman Thanks for the Response , i tried this way but seems not working getting same like earlier updated users are coming as empty value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6m ago
Hello @harinya,
It seems the issue is related to the values being passed into the custom Flow Action rather than the Action script itself.
Based on the behavior you're describing and the screenshots shared, the inputs do not appear to be getting passed as a comma-separated list of sys_ids.
When Flow Designer receives a GlideRecord or record object instead of a string, it can result in values such as: [object GlideRecord]
which would explain why your script is unable to split and compare the values correctly, causing the updated_users output to be empty.
I was able to replicate a similar scenario in my PDI, and the custom Action worked as expected when the inputs were passed directly as the sys_id values from the List Collector variable.
I would recommend verifying that:
- The Current Users input is receiving the actual glide list value (comma-separated sys_ids).
- The Users To Remove input is mapped directly from the List Collector variable.
- No record objects or GlideRecord references are being passed into the Action inputs.
- There doesn't appear to be an issue with the Action script itself. The focus should be on ensuring the inputs are passed in the correct format.
Hope this helps!
Thank You!
Juhi Poddar