How to get the display value of a reference field in Flow Designer script?

gjz
Mega Sage

I have created a flow for a custom task and need to add some details to the description in the task and email that is generated later.  I'm using a script to get the details, however, for the reference field I can't seem to get the display value and need some help on how to get that in a script for flow designer.

Here's what I have done:

1. Created a flow variable called emailDesc

2. Added Lookup action to the flow (more than one record will be found)

3. For each item in the lookup, set the flow variables.  This is where I have the script.

find_real_file.png

find_real_file.png

This is the script for the variable:

// first time in the loop to set the value as is

if (fd_data.flow_var.emaildesc) {
return fd_data.flow_var.emaildesc = 'Product model: ' + fd_data._3__for_each.item.model.display_name.toString() + '\n' + 'Part number: ' + fd_data._3__for_each.item.part_number;
}
for each run after the first run, add newline and additional data
else {
return fd_data.flow_var.emaildesc + '\n\n' + 'Product model: ' + fd_data._3__for_each.item.model.display_name.toString() + '\n' + 'Part number: ' + fd_data._3__for_each.item.part_number;
}
 
I've tried various scripts, none seem to work.  Any help would be appreciated.

 

1 REPLY 1

OlaN
Giga Sage
Giga Sage

Hi,

Try something like this in your script:

// first time in the loop the variable is empty, set the first data
if (fd_data.flow_var.emaildesc == '') {
  return fd_data.flow_var.emaildesc = 'Product model: ' + fd_data._3__for_each.item.model.display_name.toString() + '\n' + 'Part number: ' + fd_data._3__for_each.item.part_number;
}
// for each run after the first run, add newline and additional data
else {
  return fd_data.flow_var.emaildesc += '\n\n' + 'Product model: ' + fd_data._3__for_each.item.model.display_name.toString() + '\n' + 'Part number: ' + fd_data._3__for_each.item.part_number;
}