Recently I saw one question in CRM forum where user was interested in using Business Rules to implement data validation for Data Import? so can we do that ?? The answer is Yes !!, of course we can do that, business provides support to run your logic on server side right, if you don’t know this, check our earlier article first, but from end user perspective it will not be helpful.
Let’s see this in action using a quick business rule on Contact entity. Suppose we have couple of fields which is required and we want to cancel data import if those set of fields are missing in import file. Let’s say we want to enforce user to supply contact’s email and phone number:
So let’s setup quick business rules for contact entity to show error message if contact’s email or phone number is null.
If you are new to business rule, please check our earlier articles
- Navigate to your Dynamics 365 customer engagement application or you can setup a trail, using our earlier article
- Create custom solution and contact entity in our solution.
- Expand entity node under Components
- Select Contact and select Business Rules under Contact entity node
- Click on New under business rule tool bar to create new business rule
- Click on Add condition and add two rules one for email and one for phone, we can use or operator between them.
- Add Show Error Message action, to show error message, write some message. After completion it should look something like below:
8. Now make sure to set scope of business rule as Entity (Because we want to make sure this should run from server side call)
9. Save and activate business rule.
Now when we will import contact record, with missing email or phone number, it will show us error
So as you can see the message is not user friendly so we should look for other more options which can provide more user friendly message.