web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Adding series of Compo...
Power Automate
Answered

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

(0) ShareShare
ReportReport
Posted on by 9

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.

Categories:
I have the same question (0)
  • Verified answer
    Paulie78 Profile Picture
    8,422 Moderator on at

    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 😘

  • SaltySteve1706 Profile Picture
    9 on at

    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.

  • Paulie78 Profile Picture
    8,422 Moderator on at

    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 Profile Picture
    9 on at

    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.

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard