Flow Designer - need help with sending email

JLeong
Mega Sage

Hi Guys,

I need to send an email from a Flow Designer. The email must contain the values of a list collector. I need help adding these values to the body of the email.

Example email:

Hi Joe,

Request #123456 has been completed. You are now the owner of the following accounts:

  1. List collector value 1
  2. List collector value 2
  3. List collector value 3

 

Please assist.

Thank you!

Regards,

Jocelyn

 

 

 

1 ACCEPTED SOLUTION

@JLeong 

you cannot use For each loop directly on list collector variable.

you will have to convert String and return String Array which can then be used in For Each

Refer below links for help and the steps

Flow Designer

How to iterate an Array.String in the flow designer?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

11 REPLIES 11

 

Your case bit mix of data pill and scripting so i can suggest one work around. 

First type whatever thing you want in email body. Mainly static text and with desired html design (bullet, bold etc). 

find_real_file.png

Then copy the source code ('<>' icon on editor)

find_real_file.png

Now you need to replace 'number' with request number data pill and add account as '<li>' with actual value. So clear this body and start writing inline script.

/*
**Access Flow/Action data using the fd_data object. Script must return a value.
**example: var shortDesc = fd_data.trigger.current.short_description;
**return shortDesc;
*/
var htmlPrefix = '<p>Hello Joe</p>\n'+
'<p>Request <strong>'+fd_data.trigger.current.number+'</strong> is completed. You are owner of,</p>\n'+
'<ol>';

var htmlpostfix = '</ol>'

----
your script
while(sftp.next()){
    htmlPrefix+='<li>'+sftp.getValue('u_account_id')+'</li>';
}

var html = htmlPrefix + htmlpostfix;

return html;

 

Please mark correct & helpful if that works.

Regards
Deepen shah
aavenir.com

@JLeong 

you cannot use For each loop directly on list collector variable.

you will have to convert String and return String Array which can then be used in For Each

Refer below links for help and the steps

Flow Designer

How to iterate an Array.String in the flow designer?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

Thanks again 🙂

Is there a way to use the data pill to add the values of the list collector to the body of the email?

Regards,

Jocelyn

@JLeong 

please check this in body script section

var variableDisplayValueArray = fd_data.trigger.request_item.variables.list_collector_variable.getDisplayValue();

// now iterate over this array in email body script

find_real_file.png

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@JLeong 

Let me know if that answered your question.

If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader