Forum Discussion

JonathanHeuer's avatar
JonathanHeuer
Qrew Cadet
5 years ago

Converting from multi-line to rich text field without losing line breaks

I'd like to change the field type of an important field from multi-line to rich text. I have thousands of records with valuable data in this field, and don't want to lose existing line breaks. Despite the suggestion made in this other discussion thread, it doesn't work to simply replace "/n" with "<br>". According to QB Support, some of the line breaks are represented by "\r". And if you try substituting "\r" in a text formula, it breaks.

My intended process would be:
  1. Transform existing multiline data into a new field with <br> tags using a formula like
    If(
       Contains([Description of Service], "\n"),
         SearchAndReplace([Description of Service], "\n", "<br>"),
       Contains([Description of Service], "r"),
         SearchAndReplace([Description of Service], "r", "<br>"),
       [Description of Service]
    )
  2. Export all records in table
  3. Change field type of the original field to rich text
  4. Import data into transformed field
  5. Live happily every after.
Any suggestions on how to accomplish?

------------------------------
Jonathan Heuer
------------------------------

5 Replies

  • DonLarson's avatar
    DonLarson
    Qrew Commander
    Jonathan,

    A QB if statement will escape when it hits the first True condition.  Imagine a record where both are present, this will only get the first one.

    I suggest exporting all the records and writing a short PHP script to go through the entire data set and change both.

    ------------------------------
    Don Larson
    Paasporter
    Westlake OH
    ------------------------------
    • MarkShnier__You's avatar
      MarkShnier__You
      Icon for Qrew Legend rankQrew Legend
      try this logic

      var text ReplaceN =SearchAndReplace([Description of Service], "\n", "<br>")
      SearchAndReplace($ReplaceN, "\r", "<br>") 


      ------------------------------
      Mark Shnier (YQC)
      Quick Base Solution Provider
      Your Quick Base Coach
      http://QuickBaseCoach.com
      mark.shnier@gmail.com
      ------------------------------
      • JonathanHeuer's avatar
        JonathanHeuer
        Qrew Cadet
        Thanks Mark. I tried your suggestion and doesn't work. When you try saving the formula QB takes out the second escape.

        ------------------------------
        Jonathan Heuer
        ------------------------------
    • JonathanHeuer's avatar
      JonathanHeuer
      Qrew Cadet
      Thanks for suggestion Don. No hablo PHP but perhaps I can open in some text editor and try the search/replace feature.

      ------------------------------
      Jonathan Heuer
      ------------------------------