Flow Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday - last edited Tuesday
inputs i have taken as the array.string(string, array.object )all i tried but the updtaed users is coming as empty
Any suggestions, examples, or best practices would be greatly appreciated.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
Hi @harinya ,
What you're experiencing is a common Flow Designer behavior when working with Catalog Item List Collectors and Glide List fields.
Although a Glide List is ultimately stored as a comma-separated string of sys_ids in the database, Flow Designer often deserializes List Collector values into record collections (Array.Object, Array.Reference, or Array.String) at runtime. That's why you're seeing record metadata (sys_meta, etc.) instead of simple sys_id strings.
Why your current action is returning an empty result
Based on your screenshots, the most likely cause is a data type mismatch:
One collection contains record objects.
The comparison logic expects native strings/sys_ids.
Comparing a complex object to a string will never match, resulting in an empty output array, which then .join(',') turns into an empty string.
Recommended Approach
I highly recommend keeping your Custom Action (and avoiding Flow Designer For Each loops, which add unnecessary execution overhead and database threads for simple array subtraction).
You just need a script that normalizes both inputs to primitive sys_id strings before performing the comparison. Because Flow Designer's script engine can be finicky with object wrappers, here is a robust approach to achieve exactly what you need.
1. Configure your Action
Inputs: current_users and users_to_remove (configure the inputs to match the data type being passed by Flow Designer—Array.String, Array.Object, or Array.Reference depending on the source data pill).
Output: updated_users (set this to type String).
2. Use this Script
(function execute(inputs, outputs) {
var currentUsers = inputs.current_users || [];
var usersToRemove = inputs.users_to_remove || [];
// Helper to safely extract a primitive sys_id from Flow Designer objects or strings
function getSysId(val) {
if (!val) return '';
if (typeof val === 'string') return val.trim();
if (typeof val === 'object' && val.sys_id) return val.sys_id.toString();
return val.toString();
}
// Build a fast lookup map for users to remove
var removeMap = {};
for (var i = 0; i < usersToRemove.length; i++) {
var sysId = getSysId(usersToRemove[i]);
if (sysId) removeMap[sysId] = true;
}
// Filter the existing users
var updatedUsers = [];
for (var j = 0; j < currentUsers.length; j++) {
var currSysId = getSysId(currentUsers[j]);
if (currSysId && !removeMap[currSysId]) {
updatedUsers.push(currSysId);
}
}
// Output the final comma-separated string to update the Glide List
outputs.updated_users = updatedUsers.join(',');
})(inputs, outputs);Once this runs, simply drag the String output pill directly into an Update Record action for your Stakeholder's user_list field.
What to Verify Next
If you still face issues, open your Action Execution Details, inspect one element from the inputs, and confirm whether the payload contains:
{"sys_id":"..."}or
62826bf03710200044e0bfc8bcbe5df1
The script above safely handles both, but verifying the payload will help you understand exactly how your specific catalog variables are being handed to Flow Designer.
Hope this helps!
Please mark this answer as Helpful if it resolves your question. 🙂
Thanks,
Yogesh Bhatt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
Approach
1) use 2 flow variables 1 for each list collector
2) use Set Flow Variables flow logic to set the flow variables and store comma separated sysIds in that using script
3) then pass these 2 flow variables to your custom flow action and then handle the logic in script
💡 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