Tag Archives: line breaks

Show Consecutive line breaks in alerts in Dynamics 365/ CDS

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com

By this time all of us are familiar with Xrm.Navigation.openAlertDialog. What’s more is going to be there in that API. After all it’s an API which just shows some alert.

And yet the simplest of things sometime surprises us. The same experience I had today while dealing with a requirement. It was a simple alert statement where I need to show a  text with couple of consecutive line breaks.


Something like “This is the first line <Line break> <Line Break> This is the second line

Piece of cake right? All we need to do is assign variable with the below code and show it in the alert.

var alertText = “This is the first line. \n \n This is the second line.”;

I was pretty much optimistic that this would work. And this is what it came out.



As you can see there is a single break in between the two lines. While we may all have our arguments asking customer to be content with a single line break, it is pretty awkward to tell the customer that a simple thing such as this is not possible to make it work. I was kind of ashamed to say that it is not working. So devoted some more time to it.

A bit of research and then I understood there should be some characters in between two line breaks to make it work. Unfortunately “space” character of keyboard is not working. If you see my text statement, I already have a space in between line breaks.


And then suddenly a eureka moment. How about some invisible characters in between the two line breaks. So I went to the below website and copied some invisible space equivalent characters.


And it worked. But it is highlight unlikely to continue like this. How about replicating this character in code. So below is what I did.


var alertText = “This is the first line. \n” + decodeURI(“%E2%80%8A”) +”\n This is the second line”;

And this is what we get.


Sounded pretty interesting and thought to share.

Hope this helps!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)