List Collector field into Send Email action step in Flow Designer

JustinF608
Kilo Contributor

In my Flow -- I have a List Collector field. I also have an email step, currently when I send the email, it sends out sys_id's in the Send Email action. I need to send the Label. 

In my flow:

Step 1: Good

Step 2: Good

Step 3: Look Up Records step/action --> Condition is: sysID is one of [Name of List Collector field]

***In the Run Test step, the Label (value) is returned properly from Step 3***

Step 4: Send Email step/action --> For this step, I can't get to the pill that gives me the Label of Step 3. It's grey/unselectable. 

What is the solution for this? 

3 REPLIES 3

Deepen Shah
Kilo Guru

Hi

 

You can write script in email body like this.

var labels = "Labels ";

while(fd_data._1__look_up_records.records.next()){
    labels = labels + fd_data._1__look_up_records.records.getDisplayValue('name');
}

Update the script accordingly like

  1. fd_data.<look up step>.records.next() (refer your step3 here)
  2. Here i am using 'name' field of 'sys_user' table, you can update field from relevant table.

Please mark correct & helpful if this works for you.

Regards
Deepen shah
aavenir.com

Hi Deepen, 

Not 100% sure I follow. I can't put script in my email body, or else what's currently in the Send Email action step will be wiped out. 

Is there a reason I can't access the output values from the Look Up Records step, then use those in the Send Email step? I can see them in the pill picker, they're just greyed out. 

Hi @JustinF608 

I can see that 'Records' data pill , it's enable and can drop it on body but thing is it will always show 'sys_id' in email content.

find_real_file.png

There are two other ways,

1. Put your whole email content in script. For e.g. In script mentioned above.

var emailbody = "<html><head></head><body> some content ";

<code>

emailbody = emailbody + labels (fetched in code) ;

emailbody = emailbody + " some content </body>";

return emailbody;

 

2. Other way is create custom Action > Script step and take Look up Records as input, return label as output variable. Put this step after lookup record and before email and use this in email body. Take an example of below link,

https://docs.servicenow.com/bundle/orlando-servicenow-platform/page/administer/flow-designer/task/cr...

 

Regards
Deepen shah
aavenir.com