*** NOTE: ALL INFORMATION IS ACCURATE AT DATE OF PUBLISHING ***
So many good blog posts come about from questions asked by others in the community. Add in some collaboration, and the creative and inquisitive minds of others, and you’ve got yourself a nice work around to fix a slight annoyance. Al Eardley tagged me on Twitter with the following question. How can we prevent line breaks from being stripped out of multi-line text fields populated in a Forms Pro survey response?
@MeganVWalker I am hoping that you might be able to help being the #Forms guru that you are: Whenever I use #PowerAutomate to save a multiline field to SharePoint it loses the line breaks. How can I retain the line breaks?
— Al Eardley @ #MSIgniteTheTour (@al_eardley) January 13, 2020
I HATE not knowing the answer to things, and to this I wasn’t sure, so of course I went off to investigate. Forms Pro doesn’t strip out the line breaks, so something else must be doing it. For Al, he noticed it was happening when sending in to a SharePoint list. For me, I saw it was happening when adding responses to an email using the Outlook connector.
If you haven’t ever read Ryan Maclean‘s blog, where have you been? I’m proud to call him a very good friend, but even if he wasn’t, I would still rave about his blog, it’s awesome! So check it out. Anyway, Ryan is the one who suggested and also provided the resolution so that the line breaks can be retained, I’ve just written about it below. All credit goes to Ryan! This will have so many uses, but in this scenario let us first start with our Forms Pro survey. We have a few questions on this survey, with First Name, Last Name, then the Net Promoter Score, and finally a reason for the score given. It’s question 4 that allows for multiple lines of text.
In this scenario we are going to populate a SharePoint list with the Forms Pro responses received. Make sure the multi-line text field you are going to populate has the option to ‘Use enhanced rich text’ set to Yes.
Next we need our Power Automate flow. Here is the first part. Our trigger is based on the create of a record (the Forms Pro survey response entity). Next we will get the related Survey entity. This allows us to create a Condition to check the name of the Survey and make sure it matches the one we are looking for. If you want it to run for every survey, you can leave out the 2nd & 3rd steps.
Next we need to add a step to get the response details if the survey is the correct one. Use the Microsoft Forms connector and the Get response details action. Pick the correct survey, then use the following expression in the Response id value.
int(triggerBody()?['msfp_sourceresponseidentifier'])
Now if we move on to our next action we can use the values from the survey response and populate the various fields.
However, this is where the issue lies. Even though the survey response provided for this question can have the text in multiple paragraphs, those are stripped out, leaving us with just a mass of text without the formatting.
What we need (and thanks again Ryan!) is a compose step to sort things out and make sure the line breaks are kept. Your expression will look something like this. This is the part that will need to be replaced with whatever question response you want to pass through: body(‘Get_response_details’)?[‘r1023da0d92764a5a8bafaea47bf08572’]
uricomponenttostring(replace(uriComponent(body('Get_response_details')?['r1023da0d92764a5a8bafaea47bf08572']), '%0A', '<br/>'))
Here is how Ryan broke it down for me:
uriComponent – converts the input to it’s URI Encoded representation. In URI encoding, a Line Break is represented as %0A
replace – we’re replacing the %0A with <br/> which is the HTML encoding for a line break
uriComponentToString – converts the URI encoded representation back to a string so we can use it
Now you can use the Output from that action above and populate your Multi-line Text field in your SharePoint list (or whatever you are trying to populate).
We can see now, a nicely formatted response is added to the corresponding field in the SharePoint list.
Want to just watch how to do this? Check out the video below:
Check out the latest post:
Auto Assign Leads Without Code Using Lead Scoring & Work Assignment
This is just 1 of 477 articles. You can browse through all of them by going to the main blog page, or navigate through different categories to find more content you are interested in. You can also subscribe and get new blog posts emailed to you directly.
Nicely explained … thanks for all the Forms Pro info you provide!
You are welcome Henrik!
This is amazing! I actually needed this exact in a different scenario, I needed to pass the value of a multi line field in CDS into an email and this worked perfectly!
Nice! So glad it was useful Chris! ????
Chris, what formula did you use? I am having a hard time
Brilliant – Exactly what I needed….
Excellent! Glad it helped!
You are the best Megan V!!. Well explained and solved the problem!!
Nice! Thanks Mark!!! So glad it helped you solve a problem! 😊
Hi,
Is the process the same if the end output is an email being sent? I followed the steps but it ended up with the response that I wanted to include line breaks in, coming out blank?
Any help is greatly appreciated.
Thanks
Hi Will. If you look through your flow, one that has completed successfully, and you look at the compose step you created with the URI Component To String, does that show you an output with the correct text with line breaks? I would suggest reviewing a completed flow and look through all the steps to see what has happened. I am guessing that it’s not the email itself causing the issue of it being blank, but somewhere further up your flow.
In my scenario I am taking the multiline text column from SharePoint and adding it to an email notification.
When I copy the column it comes up as
@{triggerOutputs()?[‘body/Action_x0020_Request’]}
How would I plug that into
uricomponenttostring(replace(uriComponent(body(‘Get_response_details’)?[‘r1023da0d92764a5a8bafaea47bf08572’]), ‘%0A’, ”))
I tried this and it won’t accept it
uricomponenttostring(replace(uriComponent(body(‘Action_x0020_Request’), ‘%0A’, ”))
Hi Kevin, apologies for the delay, I have been on holiday/vacation for the past week. You wouldn’t copy the column into your email notification, but instead would select the Output value from the Dynamic content list, just like I showed in the step where the item was added to a SharePoint list.
Thanks for this super helpful guide. Question: my form has 10 separate fields that could have line breaks. My flow then takes each field and outputs it to a different cell in a Word doc table. Can I use this same technique for each field and, if so, how do I distinguish between the “Outputs” when setting up the Word doc?
Thank you!
Hi James, yes absolutely. Just name each of your 10 output steps something logical. Then when you are adding them to the fields in the word doc, you will be able to make sure you are picking the right one. If you look at the screenshot in this blog, you can see my Output step is called Multiline Text Field Compose. You can name it whatever you like. Just add in your Compose action, then click on the action ellipsis (three dots) and then select to rename it. Hope that helps!
Thanks for the quick reply, Megan. When I follow the steps now, I end up getting the code itself as my output, rather than the actual content. Flow is “Get Response Details” to Word (via Encodian’s “Convert HTML to Word” step). I’m putting in the following to the Compose step:
uricomponenttostring(replace(uriComponent(body(‘Get_response_details’)?[‘body/rbce3430851db42c9b8fa3d9b1f15640d’]), ‘%0A’, ”))
Any idea what might be happening? Really appreciate your help — this is going to make or break our usage of the Form, so hoping I can get it looking nice.
Hi James, are you pasting that directly in to the Compose step? Or clicking on Expression, then pasting it, then clicking Update?
Ah, right… sorry, dumb mistake. I’ve got it right now, but I’m getting a blank output on the Word doc. Any ideas? Thanks!
Just part of the learning process of Power Automate! Can’t tell you how many times I’ve made mistakes! I’ve not used the Encodian connector, so not sure why it’s blank. Perhaps message their support if they have a way of contacting them?
Thanks, Megan — I’ll reach out to Encodian. Definitely seems to be the variable here. I so appreciate your time and help!
My pleasure! Hope you can get it sorted!
Just wanted to close the loop in case it helps anyone else. I ended up just skipping the Compose step altogether and putting the following expression directly into the HTML-to-Word output step from Encodian:
uriComponentToString(replace(uriComponent(outputs(‘Get_response_details’)?[‘body/rbce3430851db42c9b8fa3d9b1f15640d’]),’%0A’,”))
Thanks again to Megan for all the help — never would’ve gotten there without you. Will definitely be bookmarking this site for the future!
Awesome, glad it worked out! Good to know Encodian will take those expressions directly and that gave you what you needed. 👍🏼
I have a similar issue but I am using the select option to get Data into an HTML table and can’t get it to give me new lines.
I have a list of students (1200) each have results of various assessments completed and I have set up a Form, which acts as a trigger to get the results from a Sharepoint List. It all works well but I can’t get each separate result as a new row – instead, it concatenates the data – here is the file:
Any help would be amazing
Hi Mark, I removed the link as WordPress didn’t seem to like it. If you want to email me hello at meganvwalker.com and I will see if I can help.
Hi Megan,
I have followed the guildine you have provided and the text is missing from the email, when I put compose before the action to send an email in Power Automate.
Does this compose only work with MS forms Pro, not the MS forms?
Best Regards,
Pipat J.
Hi Pipat. This is only form Forms Pro which is now Dynamics 365 Customer Voice, and not for regular Microsoft Forms.