How do I populate a list collector value to a work note?

vidhya_mouli
Giga Sage

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?

 

1.png2.png

1 ACCEPTED SOLUTION

Hello @vidhya_mouli 

 

You need to first create Flow variable.

 

1. Create flow variable of type JSON.

 

VishalBirajdar_0-1695903817629.png

 

VishalBirajdar_1-1695903858425.png

 

Step 2 : Add flow logic to set the flow variable 

Select flow variable name just create above in step and script

 

VishalBirajdar_2-1695903926942.png

 

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

VishalBirajdar_5-1695904413411.png

 

 

Output : 

 

VishalBirajdar_4-1695904362669.png

 

Please let me know if you need any help...!!

 

 

 

 

 

 

 

 

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

View solution in original post

5 REPLIES 5

Vishal Birajdar
Giga Sage

Hi @vidhya_mouli 

 

You can use script to get User's name from list collector.

And then update

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Can you help me with the script? I am not sure on how to do scripting?

Hello @vidhya_mouli 

 

You need to first create Flow variable.

 

1. Create flow variable of type JSON.

 

VishalBirajdar_0-1695903817629.png

 

VishalBirajdar_1-1695903858425.png

 

Step 2 : Add flow logic to set the flow variable 

Select flow variable name just create above in step and script

 

VishalBirajdar_2-1695903926942.png

 

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

VishalBirajdar_5-1695904413411.png

 

 

Output : 

 

VishalBirajdar_4-1695904362669.png

 

Please let me know if you need any help...!!

 

 

 

 

 

 

 

 

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Thank you. I will try this solution and get back.