
Hi there all experts.
Recently I have write a JS that modify the description of the quote.
The functionality works fine,
But I do now know why it removes the new line character(/n).
My description is sentence by sentence.
At the beginning of each sentence there is a dash character (-).
Here is the script.
function addServices(ServiceNames) {
var descriptionAttribute=Xrm.Page.getAttribute("description");
var descFieldText = descriptionAttribute.getValue();
var txt=validateIfExist(descFieldText); // It search for a specified sentence in the description and return that if that exist.
if(ServiceNames) {
if(txt) {
descFieldText=descFieldText.replace(txt, "It Includes : "
arvandServiceNames);
descriptionAttribute.setValue(descFieldText);
Xrm.Page.data.entity.save();
}
}
}
It works fine and replace the description with desired text.
But It removes all the new line(/n).
How can I handle it so that I can keep new line?
Any help will be appreciated.
Hey Albert,
Unfortunately from what you shared it is hard to give a concrete answer.
This really depends on how the description / string is stored in the Database.
I would start by checking the Quote Description attribute from the WebAPI in order to understand how the newlines are stored: https://<orgname>.crm<region>.dynamics.com/api/data/v9.1/quotes(<quoteid>)
It is also important to check the final value of the "descFieldText" after the replace with "It Includes : " + arvandServiceNames. We don't know the content of "arvandServiceNames" so this might also require a quick check.
If you have additional info based on this please let us know so we can help you further.