Replace newlines in text field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tziere
    Member
    • Jul 2020
    • 42

    Replace newlines in text field

    Hi all,

    I was wondering if and how the string\replace formula can be used to find and replace a newline by "\n". I want to format plaintext as json.
    If there is any other way to do this, I'm also open to that!

    Thanks!
  • esforim
    Active Community Member
    • Jan 2020
    • 2204

    #2
    The replace should work, so does the \n string, here is my posted about replace string:
    https://docs.espocrm.com/user-guide/...sions/#replace (https://docs.espocrm.com/user-guide/complex-expressions/#replace) (Please note, I mistakenly used Complex Expression instead of Formula, however there is a solution for both method thanks to item and Maximus) I'm trying to use the replace formula and having difficult with


    I can't find the post where I talk about new line (and other poster too).

    I haven't really try both of them together yet.

    In term of JSON, isn't JSON is just plain text, so it should be possible to format it in JSON style.

    Comment

    • dodom2
      Senior Member
      • Jan 2020
      • 198

      #3
      I just wanted to share my formula for anyone needing to remove a line break

      FIELD NAME=string\replace([[FIELD NAME]], '\n', '');

      This will take this for example

      Hello
      World

      and turn into

      Hello World

      Comment

      Working...