Display Values of Catalog Variables in an Email using Flow Designer

cnharris1
Kilo Sage

Hello developers,

I know this question has been asked several times and I researched each different way but I haven't had any luck.

The backstory is that I'm building out a catalog item and once its submitted it goes through a workflow using flow designer. However, once I get the catalog variables, I want to send an email to certain individuals once the request is created, which I have that part working. The problem is that I'm trying to get all of the catalog variables in that email. I know I can just drag and drop the data pills but instead of giving me the display values, I'm getting the sys ids. So I tried using a script to pull in the catalog variables, which technically works but it only gives me the first variable and not all of them. Is there a way to get the display value of all the catalog items dropped into the email using flow designer?

Here's a copy of my 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 submitter = fd_data.trigger.request_item.variables.submitter.getDisplayValue();
return 'Requested by: ' + submitter;

var emailt = fd_data.trigger.request_item.variables.email_address.getDisplayValue();
return 'Email address: ' + emailt;

var dept = fd_data.trigger.request_item.variables.department.getDisplayValue();
return 'Department: ' + dept;

var type = fd_data.trigger.request_item.variables.project_type.getDisplayValue();
return 'Project type: ' + type;

var intiativen = fd_data.trigger.request_item.variables.initiative_name.getDisplayValue();
return 'Initiative name: ' + intiativen;

var int_desc = fd_data.trigger.request_item.variables.initiative_description.getDisplayValue();
return 'Initiative description: ' + int_desc;

var srevp = fd_data.trigger.request_item.variables.accountable_srevp.getDisplayValue();
return 'Accountable SREVP: ' + srevp;

var risksa = fd_data.trigger.request_item.variables.risks_associated_with_the_initiative.getDisplayValue();
return 'Risks associated with the initiative: ' + riska;

var resourcesd = fd_data.trigger.request_item.variables.resources_needed.getDisplayValue();
return 'Resources needed: ' + resourcesd;

var tsdate = fd_data.trigger.request_item.variables.target_start_date.getDisplayValue();
return 'Target start date: ' + tsdate;

Here's the context of what I'm using it for:
 
find_real_file.png
 
And here's what that script is returning:
 
find_real_file.png
 
Any help or guidance will be greatly appreciated!
 
Best regards,
 
 
cnharris
1 ACCEPTED SOLUTION

OlaN
Giga Sage
Giga Sage

Hi,

The problem with your script is that you use "return" to early, it stops the script and returns, so the rest of the script is not evaluated.

You can change your script into something like this:

var mailtext = '';

var submitter = fd_data.trigger.request_item.variables.submitter.getDisplayValue();
mailtext += 'Requested by: ' + submitter;

var emailt = fd_data.trigger.request_item.variables.email_address.getDisplayValue();
mailtext += 'Email address: ' + emailt;

//... and continue on with all the other variables

return mailtext;

View solution in original post

12 REPLIES 12

Hi,

I also agree with Nia, you should use the low code approach whenever possible.
Although in some cases it is still necessary to write some code.

Regarding your issue with expanding a List collector variable, you could do a workaround, to get the records needed.
A List collector is actually only a comma separated string of sysIDs to records on a specific table.
So if you would need you could first retrieve the records by using the "Look up records" action, and in the condition field, select Sys ID in "List collector value"

Example below:

find_real_file.png

OlaN
Giga Sage
Giga Sage

Hi,

The problem with your script is that you use "return" to early, it stops the script and returns, so the rest of the script is not evaluated.

You can change your script into something like this:

var mailtext = '';

var submitter = fd_data.trigger.request_item.variables.submitter.getDisplayValue();
mailtext += 'Requested by: ' + submitter;

var emailt = fd_data.trigger.request_item.variables.email_address.getDisplayValue();
mailtext += 'Email address: ' + emailt;

//... and continue on with all the other variables

return mailtext;

Hello everyone, 

 

In Flow Designer, how can I script the "TO"  field so if specific applications are checked then the email should only go out to the approvers for that applications. For example, I have about 20 applications listed on the form to be selected, but if only Longview and PRO apps are selected on the form , then email should only go out to the approvers in a single email string. Is that possible? 

 

BrianDean1_0-1676344243435.png

 

Hi Brian,

I would ask that as a new question.

But in general, the scripting should return a string that contains one or more email addresses that is used as senders in your email.

Will do, thank you.