web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

Replace function remove new line

(0) ShareShare
ReportReport
Posted on by 458

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.

I have the same question (0)
  • Filipe Relvas Profile Picture
    Microsoft Employee on at

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
11manish Profile Picture

11manish 176

#2
ManoVerse Profile Picture

ManoVerse 158 Super User 2026 Season 1

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 57 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans