Sunday, April 9, 2017

Form notifications in Dynamics CRM

Form Notifications have been covered elsewhere already. When you are on a form, there is an area right below the title area that form messages are displayed.

The messages can be errors, information or warnings. In your web resources, you can add messages to the notification areas using Xrm.Page.ui.setNotification.

The picture below does not have  messages:


If a message is generated:
 
You can create your own messages in JS as mentioned above:


There is also an undocumented function, setFormHtmlNotification, that allows you to set the formatting of the message. While its not official API, its been around for awhile and saves you from having to use something like notifyjs. So if you use  

Xrm.Page.ui.setFormHtmlNotification("<h1>Wow! <button type='button'>Push Me For More!</button></h1>", 'INFO', "100")

then you get:

Don't forget to add some styling via inline styles. It's not stable API of course, but it helps. Hacking into notifications otherwise is a bit non-portable which is why notifyjs exist. Styling can also be a bit awkward.

No comments:

Post a Comment