{Dynamics CRM 2013} Clear out field value using Dynamics CRM 2013 Business Rules? Yes you can!

Business rules are great. Aren’t they? But how many implementations I have seen where customers initially were so much excited about no code development using business rules and finally they found that very simple stuffs cannot be achieved using Business Rules and finally they end up disappointed.

I faced a very similar situation recently. I had a requirement where I had to set a particular field value to something if a condition satisfies and clear it out if the condition does not satisfy. Well very simple requirement isn’t it. I suggested we use custom XRM scripts to do the same but client asked back with much surprise – Business Rule cannot do this? Considering my love for Dynamics CRM, I decided to give it a try.

To continue reading the post, you have to be aware that business rules are internally process records in CRM. If you are not aware of this, you should check out my other blog post –

https://debajmecrm.com/know-how-are-business-rules-created-as-process-records-in-crm/

 

In my example I created two Business Rules for my account entity

  • If Address 1: City equals Bangalore, then populate “Account Number” field as “BNG001”
  • If Address 1: City does not equal Bangalore, clear out “Account Number” field.

Not a very logical requirement but good for our demo. Check for the screenshots below:

image

 

image

In the rule “Address 1: City not equals Bangalore”, I have set Account Number to some “[PlaceHolder Text]”. Remember we are going to set is null. Since you cannot enter empty values here in UI, hence the place holder text. Don’t worry we are going to change it soon!

Now I activate both the rules and export the solution. Once exported I extract the solution. And this is what you find in the extracted solution.

image

 

Open the workflows folder and you can see your Business Rules

image

I open the Business Rule – “Address 1: City not equals Bangalore” and put the content in a XML editor. Once you do that, search for the keyword “SetAttributeValueStep”. Please check the screenshot below where you can see the placeholder text that we set before.

image

Replace the placeholder text with empty string and save the file.

image

Zip back the entire extracts of the solution so that it can be imported back.

Now once you import the solution back, you can see the change in effect.

image

image

Voila! you are there. One more thing, what does CRM return when you query the account number attribute using XRM script. Well lets see.

image

 

No problem. It returns null.

Hope you liked it.

6 thoughts on “{Dynamics CRM 2013} Clear out field value using Dynamics CRM 2013 Business Rules? Yes you can!”

  1. Good job with this Blog Post.
    I had some free time today and exploring your blog was a pleasure. Please display a statutory Warnings as well – Unsupported Configurations should be implemented on developers own risk. 😀
    Great job buddy.

Comments are closed.