Carriage Returns and/or Line Feeds in Single Line of Text Data Field RRS feed

  • Question

  • Using CRM 2011 On-Premise

    we have a custom entity with a field that is a single line of text  - data format = Text Area.

    Because the format is text area if the user enters data like below:

    test 1

    test 2

    test 3

    it will be displayed on the form as it was entered.

    however we also have an external asp.net mvc site which displays data from this database field and in this case it will display the text as test 1 test 2 test 3

    Does CRM remove carriage returns when saving the data to the database and if so it would sound like there is not much possible in this case correct?


    Thursday, May 7, 2015 8:52 PM

All replies

  • Hello,

    I checked the database and yes they are removed. I was thinking about a possible solution to this problem. If you really really really need this, you could create a custom multi line field 'formattedvalue'. Hook a keydown event to your multi line field (unsupported)  Dynamics CRM 2011 Calling OnKeyDown With Javascript , add every character to your custom 'formatted value field'. If the key is a carriage return add a "&#13" (HTML entities) to your string. Make your string look like "test1 &#13 test2 &#13 test3". In the MVC application, get the formatted value string and show this one in a html control. http://stackoverflow.com/questions/8627902/new-line-in-text-area . 

    Good luck,

    Kind Regards

    Friday, May 8, 2015 8:54 AM
  • Thank you,

    This is what I thought - curious how CRM itself is able to do this on the form with the text area format for the single line of text attribute.


    Friday, May 8, 2015 11:16 AM
  • The data is stored in CRM / SQL with a \r\n, but of course an HTML web control will not interpret those correctly.  I believe CRM uses an RTF control to interpret them correctly, depending on the entity.

    In your web app, try doing this:

    xxxx.replace("\r\n", "<br />")

    If you want to write it back to CRM from your web app, you will need to reverse this.

    Note:  It might just be a \r or just a \n and not both, so modify the replace statement appropriately, I am writing this up from memory.  :)

    Tuesday, May 12, 2015 3:16 PM