Since January our company is building a new solution on Dynamics CRM 2015. A very complex application to solve complex problems for large enterprises, and that can be hosted on both CRM online and CRM 2015 on-premise. Within this solution we are relying on the enhanced business rules that were introduced in CRM 2015.
In my opinion enhanced business rules are the best thing since slided bread . Finaly our data is protected on both form level and on entity level. This means that every change we make to the data through the SDK is done against the set of rules we defined on the entity.
During our development process we are working in a DTAP environment, meaning that our solution gets deployed on a daily basis from development to test etc. We export our solutions as managed solution from our development environment, and import it later on in our testing environment etc.
Things seemed to work fine, until recently. Out of the blue our business rules started to behave in a non consistent way. Rules were firing in a different sequence etc. This worried us, since we have over 130 complex enhanced business rules helping us to build our application logic…
One of my colleagues, responsible for the functional side of things, decided to investigate what business rules were present. She was shocked as it turned out that all ehanced business rules were duplicated multiple times.
I decided to do a small test, which I will describe below:
Start with a clean solution
For my investigation, I created a new solution with a custom entity. On that custom entity I defined a value field. On that value field I implemented two enhanced business rules (rule scope set to Entity). I saved, published and activated the rules. So far so good…
Export the solution / Import the solution
I exported the solution as a managed solution, and removed the original unmanaged solution.
Then I imported the managed solution, and performed an advanced find to see what business rules where present.
Search “Processes”, filter on Categoty equals Business Rule AND Primary entity equals [Entity Name]
Executing the query, gave me the following results:
I retrieved the two rules, I defined on the entity. Both were inactive and I activated them. For some reason the business rules were doubled!?
I selected all rules, deactivated them, reactivated them for a couple of times…. I ended up with more and more business rules (at every activated one new instance per business rule appeared)
*WUT?!* This is not good at all! This probably explains why the business rules in our product are behaving in a non consistent way (as we speak we are working on a workaround for this problem).
Anyway, I decided to delete the additional set of business rules, after all I only need one instance of a rule. I selected the rules and deactivated them.
I pressed the delete button, and was confronted with an error message.
Translation: “An error occurred. The selected action has not been completed for one or more records”. A number of instances had been dropped.
When I select the deactivated instance of the business rule and try to delete it, I get confronted with the following error message:
“The object you tried to delete is associated with another object and cannot be deleted.”
Things get worse from here…. When I want to remove my solution, I get the following error message:
Translation: “SdkMessageProcessingStepImage cannot be removed because this is needed for one or more parts”.
I decided to deactivate the two remaining business rules and to delete them. That seemed to work.
When I do another attempt in removing the solution, I get confronted with another error message:
I got stuck. I have a solution that I cannot remove…
I think we might have found a bug….. Houston we have a problem!