Discussions

Expand all | Collapse all

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

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

    Posted 01-30-2020 09:44
    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
    ------------------------------


  • 2.  RE: Converting from multi-line to rich text field without losing line breaks

    Posted 01-30-2020 10:50
    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
    ------------------------------



  • 3.  RE: Converting from multi-line to rich text field without losing line breaks

    Posted 01-30-2020 12:42
    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
    ------------------------------



  • 4.  RE: Converting from multi-line to rich text field without losing line breaks

    Posted 01-30-2020 13:09
    Thanks Mark. I tried your suggestion and doesn't work. When you try saving the formula QB takes out the second escape.

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



  • 5.  RE: Converting from multi-line to rich text field without losing line breaks

    Posted 01-30-2020 13:11
    Can you try this

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


    ie try a double backslash

    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    mark.shnier@gmail.com
    ------------------------------



  • 6.  RE: Converting from multi-line to rich text field without losing line breaks

    Posted 01-30-2020 13:08
    Thanks for suggestion Don. No hablo PHP but perhaps I can open in some text editor and try the search/replace feature.

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