Country field display Sysid in flow designer body

chrisfola
Tera Contributor

Hello guys,

Please can someone be kind enough to help me edit below Script using specified information: 

Field name: Country

Travel location field name: u_country_name

Ref Table : u_travel_locations

 

Script:

(function execute(inputs, outputs) {
var ids = inputs.variable.toString().split(','); //Assuming varaible contain comma-seperated Sys IDs
var userNames = [];

ids.forEach(function(id) {
var gr = new GlideRecord('sys_user'); // using 'sys_user' because it is the user table
if (gr.get(id)) {
userNames.push(gr.name.toString()); // Extracting the 'name' field from each user record
}
});
outputs.variable = userNames;
})(inputs, outputs);

 

chrisfola_1-1719315847963.png

 

I originally created a "List collector array" for name field displaying as SysId using below script in Action designer and it worked. Now I would appreciate help with similar script to display Country name instead of SYSID in the body of the flow designer email template.

 

Below is the screenshot of the name translation from SYSID to Displayname

chrisfola_0-1719314972911.png

 

Thank you inadvance for your assistance and Time.

 

Regards

Chris

1 REPLY 1

Mark Manders
Mega Patron

A list field will contain the sys_id's, so if you use that outcome to show in something else, you will have the sys_id. You will need to do a lookup to the record with this sys_id and get the name from that record. So just a simple step in between.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark