Get display value from workflow data pill

MBarrott
Mega Sage

Is there a simple solution to getting the display value from a data pill rather than the sys_id?

 

I'm sending an email via a workflow and would like to show the actual names of the users select in a members list rather than their sys_ids. 

1 ACCEPTED SOLUTION

MBarrott
Mega Sage

Managed to figure this out. 

A foreach loop does suffice but didn't meet the formatting I wanted. 

The solution I used was to set a flow variable, returning an array of the data. 

 

var resMembers = fd_data.trigger.current.members_list.split(',');
var memberArr = [];
resMembers.forEach(function(id)
{
     var usergr = new GlideRecord('sys_user');
     if (usergr.get(id))
     {
        memberArr.push((usergr.name));
     }
});

return memberArr.join(', ');

View solution in original post

3 REPLIES 3

Natan F Rosa
Kilo Guru

Hi @MBarrott 

In the flow we have this, when we get a reference type field, the sys_id will always appear instead of the display value.

To get around this, you can do a lookup record inside a forEach and use a flow variable to create a list with the names of the records found in the lookup.

If my answer helps you in any way, please mark it as correct.

MBarrott
Mega Sage

Managed to figure this out. 

A foreach loop does suffice but didn't meet the formatting I wanted. 

The solution I used was to set a flow variable, returning an array of the data. 

 

var resMembers = fd_data.trigger.current.members_list.split(',');
var memberArr = [];
resMembers.forEach(function(id)
{
     var usergr = new GlideRecord('sys_user');
     if (usergr.get(id))
     {
        memberArr.push((usergr.name));
     }
});

return memberArr.join(', ');

Natan F Rosa
Kilo Guru

Very Cool, I'm glad you managed it this way, but what I suggested is exactly that, but through the flow interface, reducing encapsulation in complexity

the flow's forEach and within it a Record lookup, and in this lookup you will use the sys_id of the forEach position to find the record and in a flow variable you concatenate the names forming an array of names.