- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2023 04:31 AM
I have a list collector (user names) in my Catalog Item (which will be populated by the user from sys_user table).
I need to display these names in the work notes. When I try to do it, it populates it with the sys_id. How do I get the names instead?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2023 05:33 AM - edited 09-28-2023 10:04 PM
Hello @vidhya_mouli
You need to first create Flow variable.
1. Create flow variable of type JSON.
Step 2 : Add flow logic to set the flow variable
Select flow variable name just create above in step and script
and use below script
var userArray = [];
var userList = fd_data.trigger.current.<Name of List field>;
// if its catalog item variable then use fd_data.trigger.request_item.variables.variable_name;
/* Glide record on user table */
var grUser = new GlideRecord('sys_user');
grUser.addEncodedQuery('sys_idIN'+ userList);
grUser.query();
while (grUser.next()){
userArray.push(grUser.getValue('user_name'));
}
return JSON.stringify(userArray.toString());
Step 3 : Drag and drop the flow variable
Output :
Please let me know if you need any help...!!
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2023 04:36 AM
You can use script to get User's name from list collector.
And then update
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2023 04:40 AM
Can you help me with the script? I am not sure on how to do scripting?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2023 05:33 AM - edited 09-28-2023 10:04 PM
Hello @vidhya_mouli
You need to first create Flow variable.
1. Create flow variable of type JSON.
Step 2 : Add flow logic to set the flow variable
Select flow variable name just create above in step and script
and use below script
var userArray = [];
var userList = fd_data.trigger.current.<Name of List field>;
// if its catalog item variable then use fd_data.trigger.request_item.variables.variable_name;
/* Glide record on user table */
var grUser = new GlideRecord('sys_user');
grUser.addEncodedQuery('sys_idIN'+ userList);
grUser.query();
while (grUser.next()){
userArray.push(grUser.getValue('user_name'));
}
return JSON.stringify(userArray.toString());
Step 3 : Drag and drop the flow variable
Output :
Please let me know if you need any help...!!
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2023 06:06 AM
Thank you. I will try this solution and get back.