
nvm - it was a problem with the debugger. Turns out getValue() does in fact return embedded \r
I am running JavaScript that needs the value of a multi-line field verbatim, but when I fetch the value using getValue() I get a string with all lines concatenated to each other without separators.
Example:
MyField value:
First line Second line
But when in the form I run the JS code below:
var text = Xrm.Page.getAttribute('new_myfield').getValue();
the value of text is 'First lineSecond line'
I really need the original, i.e. something like 'First line\nSecond line' or 'First line\r\nSecond line' or even 'First line<br>Second line'. This seems such a basic requirement that I think I am doing something wrong, in which case sorry for asking a dumb question, but I would appreciate if someone could point me to a working solution.
*This post is locked for comments
I have the same question (0)Hi there,
I stumbled upon this issue in a CRM 2016 environment as well. This thread is pretty old, but just for the record:
As it turns out, sometimes there seems to be "\r" line breaks inside those fields instead of the normal "\n" line breaks (even when entering the line breaks manually on the form).
var text = Xrm.Page.getAttribute(...).getValue().replace(/\r/g, "\n");
did the trick for me.
You can't see those carriage returns in the debugger, only if you serialize the value to json, you will see that your lines probably contained "firstLine\rsecondLine".
Kind Regards,
Florian