Discussions

Expand all | Collapse all

How do I preserve line breaks when converting multi-line text field to rich text field?

  • 1.  How do I preserve line breaks when converting multi-line text field to rich text field?

    Posted 01-24-2018 13:33
    We have a few thousand records in a table with a multi-line text field. The data in the text field often has lines breaks in order to make the content easier to read, some of them containing lists for example. I'd like to switch the field format to rich text primarily to allow users to make use of proper bullet points but I notice that when converting the fields, all of the existing line breaks are lost. Unfortunately there are far too many to manually fix after to conversion. Does anyone have an idea as to how the line breaks could be preserved?


    Example content stored in multi-line text field:


    From: MealPal [mailto:hello@mealpal.co.uk
    Sent: 24 January 2018 11:16
    To: Kipp
    Subject: New Restaurant Alert


    Same content after converting to rich-text field (loses the line breaks):

    From: MealPal [mailto:hello@mealpal.co.uk] Sent: 24 January 2018 11:16To: KippSubject: New Restaurant Alert


  • 2.  RE: How do I preserve line breaks when converting multi-line text field to rich text field?

    Posted 01-24-2018 14:33
    You need to replace each newline character (ie \n) in the Text field with <br > tags in the Rich Text field. This can be done with script using the general procedure used in this Pastie:

    How To Globally Replace String In Text Field Automatically?
    https://community.quickbase.com/quickbase/topics/how-to-globally-replace-string-in-text-field-automa...

    Here is a screenshot of me editing a modified record after manually applying similar code from the console:

    ">https://d2r1vs3d9006ap.cloudfront.net/s3_images/1696050/RackMultipart20180124-74041-13zkxoo-screenshot_inline.jpg?1516804640">

    As this code could  modify every record in a table you should only use it if you are comfortable with using JavaScript. I would further suggest you work in a copy of your production application.

    If you need personalized assistance you can contact me via the information in my profile:

    https://community.quickbase.com/quickbase/people/dandiebolt