{"id":2931,"date":"2018-02-18T11:51:12","date_gmt":"2018-02-18T11:51:12","guid":{"rendered":"http:\/\/himbap.com\/blog\/?p=2931"},"modified":"2018-02-18T11:51:12","modified_gmt":"2018-02-18T11:51:12","slug":"using-business-rule-for-data-import-validation","status":"publish","type":"post","link":"https:\/\/himbap.com\/blog\/?p=2931","title":{"rendered":"Using business rule for Data Import Validation"},"content":{"rendered":"<p>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\u2019t know this, check our earlier article first, but from end user perspective it will not be helpful.<\/p>\n<p>Let\u2019s 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\u2019s say we want to enforce user to supply contact\u2019s email and phone number:<\/p>\n<p><a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2018\/02\/busr1.png\"><img decoding=\"async\" loading=\"lazy\" class=\" size-medium wp-image-2932 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2018\/02\/busr1-300x41.png\" alt=\"busr1\" width=\"300\" height=\"41\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2018\/02\/busr1-300x41.png 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2018\/02\/busr1.png 413w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><span lang=\"EN-AU\"><span style=\"color: #000000; font-family: Calibri; font-size: medium;\">So let\u2019s setup quick business rules for contact entity to show error message if contact\u2019s email or phone number is null.<\/span><\/span><\/p>\n<p>If you are new to business rule, please <a href=\"https:\/\/himbap.com\/blog\/?p=2541\">check our earlier articles<\/a><\/p>\n<ol>\n<li>Navigate to your Dynamics 365 customer engagement application or you can setup a trail, <a href=\"https:\/\/himbap.com\/blog\/?p=2503\">using our earlier article<\/a><\/li>\n<li>Create custom solution and contact entity in our solution.<\/li>\n<li>Expand entity node under Components<\/li>\n<li>Select Contact and select Business Rules under Contact entity node<\/li>\n<li>Click on New under business rule tool bar to create new business rule<\/li>\n<li>Click on Add condition and add two rules one for email and one for phone, we can use or operator between them.<\/li>\n<li>Add Show Error Message action, to show error message, write some message. After completion it should look something like below:<\/li>\n<\/ol>\n<p><a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2018\/02\/busr2.png\"><img decoding=\"async\" loading=\"lazy\" class=\" size-medium wp-image-2933 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2018\/02\/busr2-300x70.png\" alt=\"busr2\" width=\"300\" height=\"70\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2018\/02\/busr2-300x70.png 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2018\/02\/busr2.png 521w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>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)<\/p>\n<p><a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2018\/02\/busr3.png\"><img decoding=\"async\" loading=\"lazy\" class=\" size-medium wp-image-2934 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2018\/02\/busr3-300x54.png\" alt=\"busr3\" width=\"300\" height=\"54\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2018\/02\/busr3-300x54.png 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2018\/02\/busr3.png 452w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>9. Save and activate business rule.<\/p>\n<p>Now when we will import contact record, with missing email or phone number, it will show us error<\/p>\n<p><a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2018\/02\/busr4.png\"><img decoding=\"async\" loading=\"lazy\" class=\" size-medium wp-image-2935 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2018\/02\/busr4-300x137.png\" alt=\"busr4\" width=\"300\" height=\"137\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2018\/02\/busr4-300x137.png 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2018\/02\/busr4-624x285.png 624w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2018\/02\/busr4.png 761w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>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.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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\u2019t know this, check our earlier article&#8230; <a href=\"https:\/\/himbap.com\/blog\/?p=2931\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[402],"tags":[502,501,500,466],"_links":{"self":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2931"}],"collection":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2931"}],"version-history":[{"count":2,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2931\/revisions"}],"predecessor-version":[{"id":2937,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2931\/revisions\/2937"}],"wp:attachment":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2931"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2931"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2931"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}