{"id":1421,"date":"2015-01-01T08:43:04","date_gmt":"2015-01-01T08:43:04","guid":{"rendered":"http:\/\/mahenderpal.wordpress.com\/?p=1421"},"modified":"2015-01-01T08:43:04","modified_gmt":"2015-01-01T08:43:04","slug":"business-rules-enhancement-in-ms-crm-2015","status":"publish","type":"post","link":"https:\/\/himbap.com\/blog\/?p=1421","title":{"rendered":"Business Rules Enhancement in MS CRM 2015"},"content":{"rendered":"<p>With other exciting features, Microsoft Dynamics CRM 2015 also introduced new following enhancement in business rules:<\/p>\n<ul>\n<li>Set default value<\/li>\n<li>Support for Server Side logic<\/li>\n<li>Support for OR operator<\/li>\n<li>Support for else<\/li>\n<\/ul>\n<p><strong>Setting Default Value<\/strong> \u2013 This is a very useful enhancement which can help us in different business scenarios for example, let\u2019s say you have one default pricelist that you want to set in opportunity, earlier we used to write <em>retrievemultiple<\/em> call to set default pricelist based on it\u2019s name. But now we can simply design business rule to set default price list<\/p>\n<p><a href=\"https:\/\/mahenderpal.files.wordpress.com\/2015\/01\/settingdefaultpricelistii.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-1422\" src=\"https:\/\/mahenderpal.files.wordpress.com\/2015\/01\/settingdefaultpricelistii.png?w=300\" alt=\"SettingDefaultPricelistii\" width=\"300\" height=\"111\" \/><\/a><\/p>\n<p>Once activated, it will set default pricelist when opportunity record is created.<\/p>\n<p><a href=\"https:\/\/mahenderpal.files.wordpress.com\/2015\/01\/pricelist.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-1423\" src=\"https:\/\/mahenderpal.files.wordpress.com\/2015\/01\/pricelist.png?w=300\" alt=\"pricelist\" width=\"300\" height=\"47\" \/><\/a><\/p>\n<p>This is especially useful to set some default value to required fields automatically.<\/p>\n<p><strong>Support for Server Side logic \u2013 <\/strong>Initially business rules released for client side validation, but Microsoft Dynamics CRM 2015 added support to run these validation on server side as well, so now we can configure our business rule to run both client and server side. A new scope \u201c<strong>Entity<\/strong>\u201d is added in business rules designer which enables to run our business logic at server side as well, let\u2019s take above example and activate it using Entity scope. Like below<\/p>\n<p><a href=\"https:\/\/mahenderpal.files.wordpress.com\/2015\/01\/setdefaultpricelst1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-1424\" src=\"https:\/\/mahenderpal.files.wordpress.com\/2015\/01\/setdefaultpricelst1.png?w=300\" alt=\"setdefaultpricelst1\" width=\"300\" height=\"107\" \/><\/a><\/p>\n<p>Now let\u2019s create opportunity using code, like below<\/p>\n<p>private void Businesslogicdemo(IOrganizationService iorganizationService)<\/p>\n<p>{<\/p>\n<p>\/\/Create entity class object and pass entity name<\/p>\n<p>Entity opportunityEntity = new Entity(&#8220;opportunity&#8221;);<\/p>\n<p>\/\/call create method to create opportunity<\/p>\n<p>iorganizationService.Create(opportunityEntity);<\/p>\n<p>}<\/p>\n<p>Please note we are not adding any attribute value, but as soon as this code is executed it will also run our business logic and our default values will be available in opportunity record like following<\/p>\n<p><a href=\"https:\/\/mahenderpal.files.wordpress.com\/2015\/01\/advancefind.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-1425\" src=\"https:\/\/mahenderpal.files.wordpress.com\/2015\/01\/advancefind.png?w=300\" alt=\"advancefind\" width=\"300\" height=\"75\" \/><\/a><\/p>\n<p><strong>Support for OR operator \u2013 <\/strong>Now business rule also supports OR logical operator, so we can have two condition and we can use <strong>And\/OR<\/strong> logical operator between these conditions based on requirement.<\/p>\n<p><strong>Support for else \u2013 <\/strong>This is another new enhancement in business rules, earlier there was no support for else, so if you want to make any field required based on some condition in MS CRM 2013, you need to create two business rule one to make that required and another to make that field not required, but in MS CRM 2015 we can simply add else statement.<\/p>\n<p><a href=\"https:\/\/mahenderpal.files.wordpress.com\/2015\/01\/else.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-1427\" src=\"https:\/\/mahenderpal.files.wordpress.com\/2015\/01\/else.png?w=300\" alt=\"else\" width=\"300\" height=\"107\" \/><\/a><\/p>\n<p><a href=\"http:\/\/himbap.com\/\">HIMBAP<\/a> | Need any help in Microsoft CRM 2015\u00a0<a href=\"http:\/\/www.himbap.com\/contactus.aspx\">Contact US !!<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>With other exciting features, Microsoft Dynamics CRM 2015 also introduced new following enhancement in business rules: Set default value Support for Server Side logic Support for OR operator Support for else Setting Default Value \u2013 This is a very useful enhancement which can help us in different business scenarios for example, let\u2019s say you have one default pricelist that you&#8230; <a href=\"https:\/\/himbap.com\/blog\/?p=1421\">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":[8],"tags":[38,127,139],"_links":{"self":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1421"}],"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=1421"}],"version-history":[{"count":0,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1421\/revisions"}],"wp:attachment":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1421"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1421"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1421"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}