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 / Submitted Forms respon...
Power Automate
Answered

Submitted Forms responses to populate Modern SharePoint Pages

(0) ShareShare
ReportReport
Posted on by 15

Hi,

I'm new to Power Automate and created a flow to get Microsoft Forms responses submitted to create a SharePoint page  (based on a pre-created page template) on a Modern Communication SharePoint Site; essentially following the step-by-step instruction from this tutorial: https://www.youtube.com/watch?v=QtBqeEEOgdE.

full-flow.png

My Forms has a question "Session description" that is a long text answer field and the text of the submitted response will then placed into a modern text webpart of the SharePoint page via the "Save Page - https POST" step: 

 

automate-sharepoint-https-post.png

 

However, I find that whenever the submitter include a "linebreak/next line" in their Forms response, the "Save Page - https POST" step fails and the error message I get is "BadGateway" with the message:

automate-raw-output.png

"There was an error deserializing the object of type Microsoft.SharePoint.Publishing.SitePageFieldsData. Encountered invalid character '\n'.....". Upon looking at the raw input message of that step, I see that there are these "\n" characters that are automatically injected between the sentences, which upon testing is confirmed to be when the submitter line break their text when typing out their responses in Forms.

automate-body.png

 

automate-forms-response-linebreak.png

 

I've tried looking up forums but haven't come across any resources that seem to be identical to my problem. Any help to how to clear these '\n' characters would be much appreciated, since my flow has had more Failed runs than Successful runs so far due to this error. Thank you so much!

Categories:
I have the same question (0)
  • PrasadAthalye Profile Picture
    on at

    Can you replace line break character like below?

     

    replace(variables('Melcode'), '\n', '')
    OR
    replace(variables('Melcode'), '\n', '<br>')
  • schao Profile Picture
    15 on at

    Hi PrasedAthalye,

     

    Thanks for the tip!

     

    I've tried replace expression, but the '\n' seem to be displayed only in the "Show raw input/output" and therefore it doesn't seem to be selected and replaced.

     

    Screen Shot 2021-04-22 at 3.34.24 PM.png

     

     

     

     

    As a test, I tried the following to see if maybe the way I wrote the expression is incorrect. - the following does work.

    replace(outputs('Get_response_details')?['body/rd47ed83d812c4fbfabccdbba54g913gh'], 'lorem ipsum', 'LOREM IPSUM')

      

    However when the latter part is changed to '\n' - it doesn't work.

    replace(outputs('Get_response_details')?['body/rd47ed83d812c4fbfabccdbba54g913gh'], '\n', 'WHATEVER')

     

    I have no idea how to replace the \n that's seen only in the raw data.....

  • PrasadAthalye Profile Picture
    on at

    OK. Can you use HTML to text action first to convert entire HTML to a text format and then use replace on it?

  • schao Profile Picture
    15 on at

    Unfortunately, still not working.

    I thought HTML to text fixes it, until I saw that its' raw outputs added "\n" to where the text line break to the next line in the body 🙄, which when I do the Replace expression, it still not be detected as these new "\n" is also only seen in the raw outputs.... 

     

    Screen Shot 2021-04-23 at 11.45.34 AM.png

     

    Screen Shot 2021-04-23 at 11.49.13 AM.png

     

     

     

  • Verified answer
    PrasadAthalye Profile Picture
    on at

    Try solution given in this thread...

    https://powerusers.microsoft.com/t5/Building-Flows/Replace-Newline-in-Flow-Expression/td-p/57333

     

    uriComponentToString(replace(uriComponent(body('Html_to_text')), '\n', ''))
  • schao Profile Picture
    15 on at

    Thank you so much for this, this does the trick!!

    Although it seems like the "\n" character is seen as "%0A", so I just made the slight adjustment with your suggested expression. I tested without using "Html to text" too, and the following seems to work as expected. I could probably clean up the expression nicer with additional variables.

     

    uriComponentToString(replace(uriComponent(outputs('Get_response_details')?['body/rd47ed83d812c4fbfabccdbba54g913gh']), '%0A', '<br>'))

     

    With that, it then put the text onto the page with the intended <br> as the originally submitted response thru the Microsoft Forms:

    Screen Shot 2021-04-26 at 11.36.13 AM.png

    Again, I really appreciate your help and troubleshooting with this! 

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 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard