Business Rules Enhancement in MS CRM 2015


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 – This is a very useful enhancement which can help us in different business scenarios for example, let’s say you have one default pricelist that you want to set in opportunity, earlier we used to write retrievemultiple call to set default pricelist based on it’s name. But now we can simply design business rule to set default price list

SettingDefaultPricelistii

Once activated, it will set default pricelist when opportunity record is created.

pricelist

This is especially useful to set some default value to required fields automatically.

Support for Server Side logic – 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 “Entity” is added in business rules designer which enables to run our business logic at server side as well, let’s take above example and activate it using Entity scope. Like below

setdefaultpricelst1

Now let’s create opportunity using code, like below

private void Businesslogicdemo(IOrganizationService iorganizationService)

{

//Create entity class object and pass entity name

Entity opportunityEntity = new Entity(“opportunity”);

//call create method to create opportunity

iorganizationService.Create(opportunityEntity);

}

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

advancefind

Support for OR operator – Now business rule also supports OR logical operator, so we can have two condition and we can use And/OR logical operator between these conditions based on requirement.

Support for else – 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.

else

HIMBAP | Need any help in Microsoft CRM 2015 Contact US !!

Advertisements

6 Comments

Filed under MS CRM 2015

6 responses to “Business Rules Enhancement in MS CRM 2015

  1. Nico van der Heiden

    Hi Mahender, These enhancements are really good! Especially the server side option is one that will make plugin code / integration complexity a lot easier.

    Besides that I’ve a thought about the “set default value” option. Does this work over different / cross organization without changing the business rule manually after importing?
    The reason why I think about this is because I worked a lot with business units, teams, queues etc. I have also written code to set default (active) pricelist to make sure the code / pricelist is not hard coded and doesn’t work cross environment. Because all entities mentioned above are records in the database and linked based on their unique GUID. When exporting customizations, teams etc. these links are broken because their GUID is different over all organization.

    Look forward to hear/read from you. Thanks.

    • HIMBAP

      Thank you for your comment, Sorry for late response I was out for training, No it won’t work on cross organization, so you need to manually update it in your target organization. And regarding the code you should not hard code guid while writing code instead should write a retrieve call based on name so that it can fetch records based on name and fill it, and this will also work perfectly in your target environment, but you need to make sure to have the same record on target system. hope it will help. Thank you/

      • Nico van der Heiden

        Hi Mahender,

        No worries. I appreciate your response.
        I prefer to work with a mark on the reference entity or settings entity so user can change the record of needed during time. With coding on name I can’t do that from my perspective?

        But why not hard code guid in records for reference entities (like pricelists) we can export these records with the guid and import them in THE target.

        Regards,
        Nico

      • HIMBAP

        Yes, correct we can also create system setting and use it, Importing data is another option, but it will add one more step.

  2. Nico van der Heiden

    From my perspective iT will not add one more step, because you otherwise have to manually create THE record in all systems with risk of manual mistakes. Now you create THE records once and use the same export file as import source (only first time setup) over all environments.
    But overall we agree on the possibilities we have and recognize that set default with business rules still force us to make changes to the target environment(s) after importing.
    Thanks for your reply and the discussion!

    • HIMBAP

      Actually you are correct, instead of creating importing we will be good option at least there won’t be any possibility for any typo 🙂 Thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s