Parameter used in Email Subject - Possible?

I am wondering if you can use a parameter in the subject field for an email.

I created a parameter that would derive the previous month and year and concatenate that with a string. However, when I execute the flow with the parameter selected, the email I receive has the entire javascript code as the subject not what I was hoping to return. I loosely based it off of the global parameter forum guide.

Here’s the code I wrote for the parameter. I know it doesn’t factor in the change of the year. That’s later to do on the list.

Email step
image

Outlook

Any info would be appreciated. Thanks.

Mark

Hi Mark, Yes it is possible to use Parameters in Email Subject fields.

In order to use a Solution Parameter containing code we need to first interpret the code in the flow and can then use the parameter value in the Email subject field.

In your flow, Add a Calculator step, Click on the paper clip icon and select your parameter

image

The calculator will return the object as per the below

image

In the EMail destination step, specify the Subject as per the below image

@record.subject

Please note when working with Dates in Synatic, You can make sure of the Day.js library, For more information, please refer to the below links

Using DayJS in Calculators - FAQs / Calculators - Synatic Community

Format · Day.js

Let us know if you have any further questions.
Thank you
Faizel

So I added the calculator step to parse the code but it didn’t quite do what I hoped.

Here is what the result email looked like.
image

And the contents of the attachment.
image

Perhaps I should have shared the backstory to what I was doing in my prior post. I am trying to build a simple report query that will send a monthly email. I have 95% of it complete. The only piece is the formatting of the email subject.

The first calculator step does some manipulations on the Salesforce query results, i.e. formatting, field name changes, etc. The second one parses the code from the parameter as you mentioned above.

How do I get both the query results and the parameter to be exported via the email? As you saw above the email attachment just shows the parameter value being repeated instead of the data from Saleforce.

Thanks.

Post edit

I moved the second calculator step to after the Excel step. That allowed the results to be emailed but the subject of the email still says “@record.subject”.

Hi Mark, Currently parameters aren’t supported when a Combine step is present in a flow. We have logged a support ticket with our product team, the fix should be deployed by the 1st of September 2023. I will keep you posted on the progress.

Hi Mark, We were able to get a workaround that does not require a code change

Add the Calculator to parse the Javascript code before the EMail destination step as per the below image

In the Solution Parameter update the code as per the below

let emailSubject = {};

// Set the subject property of the emailSubject object
emailSubject.subject = ‘This is the subject’; //Add JS date code here

// Assign the emailSubject object to input.totals
input.totals.emailSubject = emailSubject;

// Return input.totals
return input.totals;

Set the value on either of parameters, totals, or parentParameters in the Solution parameter’s JavaScript setting, then it can be parsed in the calculator step and referenced by using {{totals.emailSubject.subject}} or @totals.emailSubject.subject

For this use case in the EMail destination step the subject property can be referenced as:

@totals.emailSubject.subject

Please test and let us know if you have any further questions!
Thanks
Faizel.

@Faizel Thanks, I was able to get it to work. Just a note, it only worked if I used the double handlebar notation. The @ notation didn’t work.

Thanks for the feedback, Do let us know if you have any further questions!