In this webinar, our experts showcase a variety of demo use cases of how different components of the...
We've already covered how to become a pseudo-developer with business rules in CRM 2013. Today we will talk about moving business rules with static values from development to production.
The new functionality in CRM 2013 Business Rules has become a go-to feature for replacing JavaScript. Where in the past, small client side requirements such as showing and hiding fields, defaulting values or making fields required would have required a developer to write JavaScript, now these can be done with business rules and no code!
A common scenario for the use of business rules is to default values on the form. In our case, see where we user a business rule to automatically set the Default Unit, Decimals Support and Unit Group on the product form.
Let's take a closer look at the setting of the Default Unit. What we are doing in this instance is specifying a record from the Unit of Measure entity to be set every time a user enters a new product. A very straightforward example that would have to have been done with JavaScript previously.
So, we have fully tested our business rule and are ready to move it to production! If you need help with this, reference our blog on solution management and best practices.
Now, let's say you've moved your solution to production and you go for a test run and BAM! Error!
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: uom With Id = 3016b890-dafd-437a-8094-8f910666a1b4 Does Not ExistDetail:
What happened? It's a simple solution, all we're doing is defaulting a couple fields. What could have gone wrong?
Here's the catch. When you create a business rule that contains reference to a specific record (in our case the Primary Unit record in the Unit of Measure entity), the business rule is referencing the guide for that record that exists behind the scenes in the database. When we move our business rule from development to production, the business rule is still referencing the guide from development. Hence the error: "uom With ID = XXXXX Does Not Exist".
So, to fix this issue, simply:
1. Go into the business rule in production and deactivate the rule.
2. Delete the Primary Unit in question from the Value field.
3. Then re-select the Primary Unit.
That's it! Save and activate and you're all set. Now that you know what to watch for when moving business rules from development to production, check out previous posts on what other cool things you can do with business rules.
Happy CRM'ing!