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
2 hours ago
Hi @harinya
Just Change this two lines ->publish and test in real time execution
From:
var currentUsers = inputs.current_users.split(',');
var removeUsers = inputs.users_to_remove.split(',');To:
var currentUsers = inputs.current_users.toString().split(',');
var removeUsers = inputs.users_to_remove.toString().split(',');
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi @Tanushree Maiti Thanks for Response i tried this approach but didn't worked
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
the action inputs are of what type?
share screenshots of the flow action for each step
Ankur
⨠Certified Technical Architect || ⨠10x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
script is:
(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);
@Ankur Bawiskar Thanks for the Response i have shared all snaps if u can please help.