Contact Us Today!

How to avoid intrusive alerting in Microsoft Dynamics CRM

How to avoid intrusive alerting in Microsoft Dynamics CRM

I’ve seen this request come across my desk on many occasions:  “I want an alert to pop up every time a user opens a record”.  It’s a relatively easy implementation, but I often find it comes with a lot of negative feedback from the end users. EVERYTIME they open up a record, they are now guaranteed an extra click to close this popup.

Don’t you find popups annoying when you are surfing the web?  You’ll discover that most end users do too,  and they will grow numb to the message.  Is there a more elegant way to implement these alerts without annoying your end users?  Yes there is 🙂

Here’s my solution:

1.  Create a Tab called Alerts, and place it at the top of the form.

2.  Add a text field called Alert, then insert it in the tab.

3.  Uncheck the Expand this tab by default box on the tab.

4.  Add a JavaScript web resource with this code:

     

function showHideAlert() {    

        try {        

            document.getElementById("dsc_alert_d").style.backgroundColor = "#ffff00";  //yellow        

            var dsc_alert = Xrm.Page.getAttribute("dsc_alert").getValue();  //field name        

            if (dsc_alert != null) {            

Xrm.Page.ui.tabs.get("dsc_alert_tab").setDisplayState('expanded'); //tab name            

setTimeout(function () {                

Xrm.Page.ui.tabs.get("dsc_alert_tab").setDisplayState('collapsed');            

}, 10000);  //10 seconds         } }     catch (e) {         alert('showHideAlert function failed: ' + e.message);     } }

5.  Add the proper Event Handler to fire when the form loads

6.  Save and publish the form.

Are you ready to test?  Open a record and enter some information in the Alert field, then Save. Now every time someone opens up this record, they will see the alert on top of a yellow background.  This should catch their attention, right?

If you wait for 10 seconds, you will notice that the Alert tab will automatically hide itself!
This functionality is provided by the JavaScript setTimeout function, so there is no need for the user to have to click to close the message.  If the user wants to get a second look at the message, they can simply click on the Alert tab to expand it and see the message.

Bonus Code Time!
Do you have any ideas on how to enhance this process?   Perhaps by adding an Alert Type optionset to the form that would change the Alert background color to either green, yellow or red?   I’ll award bonus points for creativity.

Please contact Beringer Associates with your brilliant ideas or questions.


theProfessor

theProfessor

Rob is the CTO of Beringer Technology Group, and focuses his efforts on software development, cloud engineering, team mentoring and strategic technical direction. Rob has worked with Beringer since 2005, and has influenced every department from Development, Security, Implementation, Support and Sales. Rob graduated with his MBA from Rowan University in 2012, earned his Bachelors of Computer Science in 1997, and is current with several Microsoft technical certifications. Rob is very active, and loves to mountain bike, weight train, cook and hike with his dog pack.