Monday, March 23, 2015

A Codeless Alert System For Dynamics CRM

A common requirement for JavaScript on CRM forms is to pop up a warning when a record opens. Perhaps it is an account marked as a bad credit risk in the ERP system or perhaps it is a case overdue for a response. Whatever the circumstance, we often want to inform a user of something before they start interacting with a record.

With Business Rules, we can now interrupt a user reliably without resorting to Javascript.

Setting up the Alert

First of all we need a text field to contain our alert. Initially I added this to the header of the record but found out that it is not possible (or, at least, I could not figure out how) to widen the field meaning my alert was being cut off. In the end I added a tab to the top of the form body and added the field to a section in the tab.

image

When blank the field is almost invisible so I clicked into it for the screenshot. I also turned off the label for the field as we do not need it.

Next, I set up a business rule to grab the user’s attention.

image

All the rule does is prevent the user from saving if the Alert field contains data and forces the user to clear the field first, making them acknowledge the contents.

Triggering the Alert

Now we simply set up another Business Rule, Workflow or whatever we like to populate the Alert field. When this is done, we are set. For example, let us say we want to warn the user of all Accounts beginning with A.

image

When the user opens up a guilty record, they are confronted with:

image

Until they clear the message, they will not be able to save any changes to the record.

A word of warning though, Business Rules fire in the order they are activated so if you add a rule to populate the Alert field, make sure you deactivate and reactivate the Alert Rule afterwards so it checks AFTER the field is populated and not before.

Conclusions

A simple and effective alerting system which forces the user to read the message before interacting with the record. If you need such an alert and do not want to rely on a coder to adjust it as the business alert criteria change over time, consider this option.

No comments: