S2K
S2K

Reputation: 1285

How to concat Logic App parameter values with expressions in email connector?

I am using Office 365 send email connector to send email to multiple users.
The value of email address is determined from paramter and one of the expression like below :Json View of connector

"Send_an_email_3": {
                   "inputs": {
                   "body": {
                    "Body": "Test",
      "Cc": "@concat([parameters('email-address')],';',@{items('For_each_6')?['ChallengedBy']})",           
                      "IsHtml": true,
                                    "Subject": "Test"                                        "To": "[parameters('dtf-email-address')]"
                                  },

However, the @concat statment in CC option is not working.

"Cc": "@concat([parameters('email-address')],';',@{items('For_each_6')?['ChallengedBy']}

Error Message :

: "The template validation failed: 'The template action 'Send_an_email_3' at line '1' and column '130951' is not valid: \"The template language expression '[parameters('email-address')] ; @items('For_each_6')?['ChallengedBy'];' is not valid: the string character ';' at position '36' is not expected.\".'."

Parameter values is determined but expression is unchanged, it should evaluated as it is for subject line.

enter image description here

Upvotes: 2

Views: 16479

Answers (3)

Bin Pan
Bin Pan

Reputation: 1

Try the following expression in your ARM JSON template,

[concat(parameters('email-address')],'';'','@{items(''For_each_6'')?[''ChallengedBy'']}')]

It would be more helpful, if you can provide the raw source code of "CC" field.

Upvotes: 0

Paco de la Cruz
Paco de la Cruz

Reputation: 2154

If I understood correctly, you are trying to pass an ARM Template parameter [parameters('email-address')] to a Logic App Workflow definition language function @concat(). Adding ARM Template expressions and functions to be resolved at deployment time in a way that results in Logic Apps expressions and functions to be evaluated at execution time can be messy. Things can become harder when you have string functions in a Logic Apps, like @concat() that accept values that are to be obtained from ARM template expressions, like [parameters()] or [variables()]. At run time, the @concat() function expects something like

"Cc": "@concat('[email protected]',';',@{items('For_each_6')?['ChallengedBy']}

Which is not what you are currently getting using an ARM template parameter.

One way to do it is to avoid using ARM template parameters inside a Logic App workflow definition. I.e., create an Logic App parameter which gets the value from the ARM Template parameter, and then use the Logic App parameter in your @concat() function.

You can read the full explanation of how to do this in this post

https://platform.deloitte.com.au/articles/preparing-azure-logic-apps-for-cicd

HTH

Upvotes: 0

Joey Cai
Joey Cai

Reputation: 20067

According to my test, you could try to use the following code to test.

"Cc": "@{concat(parameters('email-address'),';',items('For_each_6')?['ChallengedBy'])}"

Upvotes: 1

Related Questions