cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SaltySteve1706
Frequent Visitor

Adding series of Compose outputs to an email separated by commas and a space.

Hi,

I have a flow that uses 8 conditions to remove the extra characters from the responses of multiple option questions in a Form and joins them separated by commas.  I then include the outputs of these in an email.  Problem is the questions are not mandatory so some can be blank.  When this occurs the email has outputs separated by multiple commas like this:

Outputs 1, Outputs 2, , Outputs 4, , Outputs 6, , .

I have tried separating each of the outputs in the email body with an expression -  if(empty(outputs('Compose_1'),'',', ')) but this just returns an invalid expression.

I am sure this is a simple fix, but I am only new to Power Automate and can't solve this.

1 ACCEPTED SOLUTION

Accepted Solutions
Paulie78
Super User
Super User

You don't need your compose actions. Multiple option form results come through as a JSON string, which can be easily transformed back to json. For example it might look like this:

 

"rbea18da1a1c84e3396b1452d9cbbc108": "[\"Power Automate\",\"Power Apps\",\"Power BI\"]"

 

You can easily turn this back into a valid JSON array with an expression like this:

json(outputs('Get_response_details')?['body/rbea18da1a1c84e3396b1452d9cbbc108'])

This will allow you to apply further expressions that are capable of manipulating arrays. For example:

join(json(outputs('Get_response_details')?['body/rbea18da1a1c84e3396b1452d9cbbc108']), ',')

This will join all of the results with a comma, and you should have the result that you need.

 

Blog: tachytelic.net

YouTube: https://www.youtube.com/c/PaulieM/videos

If I answered your question, please accept it as a solution 😘

View solution in original post

4 REPLIES 4
Paulie78
Super User
Super User

You don't need your compose actions. Multiple option form results come through as a JSON string, which can be easily transformed back to json. For example it might look like this:

 

"rbea18da1a1c84e3396b1452d9cbbc108": "[\"Power Automate\",\"Power Apps\",\"Power BI\"]"

 

You can easily turn this back into a valid JSON array with an expression like this:

json(outputs('Get_response_details')?['body/rbea18da1a1c84e3396b1452d9cbbc108'])

This will allow you to apply further expressions that are capable of manipulating arrays. For example:

join(json(outputs('Get_response_details')?['body/rbea18da1a1c84e3396b1452d9cbbc108']), ',')

This will join all of the results with a comma, and you should have the result that you need.

 

Blog: tachytelic.net

YouTube: https://www.youtube.com/c/PaulieM/videos

If I answered your question, please accept it as a solution 😘

Thanks Paulie78,

I see how the join(json expression can do away with the compose action, and have replaced all of the Compose outputs with the Join outputs.  I still need the condition to test if any response is null as using the expression directly in the email body will crash the flow if the question has not been been answered.  My problem with the email having blank spaces and extra commas where some of the questions are null still exists.  This was where I thought I could wrap the commas in an expression that either adds them or not depending on whether the question to the left in the email is empty.

Hope that explains the problem well.  Appreciate you helping out.

Why would it crash the flow? This expression:

json(outputs('Get_response_details')?['body/rbea18da1a1c84e3396b1452d9cbbc108'])

will simply return an empty string, not crash the flow. Perhaps you were missing the question mark, which would crash the flow.

SaltySteve1706
Frequent Visitor

The json expression is ok, I was putting the join(json expression straight into the email body, which crashed if the response was empty.

 

When I use it in an append to string variable it works great.

 

Thank you so much for your help.

 

 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (6,262)