Help

The Community will be temporarily unavailable starting on Friday February 28. We’ll be back as soon as we can! To learn more, check out our Announcements blog post.

Unable to create JSON friendly output - Strange Text Behavior.

Topic Labels: Formulas Integrations
1446 2
cancel
Showing results for 
Search instead for 
Did you mean: 
Matt_Kennedy1
7 - App Architect
7 - App Architect

I'm having a hard time cleaning a long text value so that it can be passed to an API as a JSON value via a Post Request.  After running lots of different cleaning formulas, which all yield 'bad character' errors, I think I've narrowed the problem down to some strange behavior re: line breaks - as demonstrated in the table below, where the same formula yields oddly different outputs for different text blocks.  

Screenshot 2023-06-25 at 6.33.09 PM.png

REGEX_REPLACE formula is used to replace ''\n" characters w/ Xs

The formula output for record A works as expected.  In Record B only some line breaks appear to have been replaced.   Record C is a duplicate of Record B that has been modified with one character "$." This modification seems to trigger the formula to find the second set of '\n' characters.  

Screenshot 2023-06-25 at 6.38.45 PM.png

In some cases, while testing this, it seems like the list view and detail view yield different results when I copy and paste them into a text editor.  One view yields collapsed text and another yields text with line breaks still in it.  I haven't had time to study this problem so it may be hard to replicate. 

Any help appreciated.

 

 

 

 

 

2 Replies 2
Sho
11 - Venus
11 - Venus

It is better to match all the line break codes, as they may differ depending on the environment

 

regex_replace("\r\n|\n|\r","X")

 

 

 

 

Thanks Sho - agreed.  This is a good technique.  However I still get the same buggy response w/ that formula.  It seems not to recognize the characters.