{Quick tip} Consecutive line breaks while showing alert in Dynamics 365

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.

image

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.

https://beautifuldingbats.com/whitespace/

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.

image

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)

Author: Debajit

I am a Dynamics CRM Most Valuable Professional (MVP) with 12 years of experience in Microsoft .NET Technologies and 9 years of dedicated experience in Microsoft Dynamics CRM. I have worked with companies like Microsoft, SanDisk, PwC, TMF Group and have extensive experience of implementing complex CRM solutions from both offshore and client side. Currently the face of XrmForYou.com with significant experience in delivering corporate training on Dynamics CRM and have already delivered multiple projects to client through XrmForYou.com Author of multiple tools on codeplex including the 'Role Based Views' and 'CRM-Sharepoint Metadata manager & Attachment Extractor' which are available for commercial use under XrmForYou.com For consulting/ training, drop me a note at info@xrmforyou.com or visit our website www.xrmforyou.com

One thought on “{Quick tip} Consecutive line breaks while showing alert in Dynamics 365”

Leave a Reply to Nishant Rana Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s