Support Article
Text Area ignores /r on line breaks over REST connector
SA-64101
Summary
Sending data from a TextArea control using REST connector fails to respect '\r' for line breaks.
The application has two buttons, Submit and Save. Submit does a form submit. Save does a refresh section with an associated data transform. Both sends the value of a text area to a REST connector. If the value in the text area is multi-line, the behavior of the two actions is different.
For example, if the value is:
1
2
3
Submit sends '1\r\n2\r\n3' which is the desired behavior.
However, Save sends '1\n2\n3'.
Error Messages
Not Applicable.
Steps to Reproduce
- Create a TextArea control in a section
- Create a Save button for the TextArea control which calls a REST connector to send the data:
{Request Message={"RHNote":"1\n2\n3","UpdatedBy":"pega"}} - Configure post action to send the data through the REST connector on click of Submit:{Request Message={"RHNote":"1\r\n2\r\n3","UpdatedBy":"pega"}}
Root Cause
The issue occurs due to the difference in the way browser encodes newline when using the encodeURIComponent browser API (%0A >> \n) and encoding the form data while form submitting (%0D%0A >> \r\n). When the refresh section is called, the post data is encoded using the encodeURIComponent API in the UI framework.
Resolution
Perform the following local-change:Implement a post activity to add the desired '\r' characters where required.
Published September 13, 2018 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.