The workflow engine in Microsoft Dynamics CRM is an area I personally spend a ton of time playing with. It is like Jscript was in Version 1.x and 3.0 for me. It has A TON of potential that many people have barely scratched the surface of.
So in working with a customer over the past month, they wanted to track the number of widgets each one of their accounts has at each location. This works well, until they want to be able to run some queries and there is no way to be able to get the total number of widgets per account. How many accounts have brand A of widgets in a quantity of over 200? How many have Brand B?
So that is where workflow comes in. In talking with Jon Goodwin from Microsoft Consulting Services, he showed me a quick and easy way to have workflow create a summary number on a parent entity. So he showed me a quick trick to be able to take quantities from a child entity and using workflow, create a summary of the number of widgets owned.
Step 1. Create Widget Entity. Add a Quantity Owned to Widget Entity. In addition, I also wanted to track by competitor, but that step isn’t used in this example. Then create a field to track number of widgets and type of widget. Step 2: Create N:1 Relationship Between Widget and Account Entities. (So the Widgets are a Child Record of an Account) Step 3: Create Summary Field on Account. (To hold how many widgets total you have!) Step 4: Create Workflow on Widget Entity. You will want the workflow to fire on the create of a Widget as well as the change of the number of widgets.
Step 1. Create Widget Entity. Add a Quantity Owned to Widget Entity. In addition, I also wanted to track by competitor, but that step isn’t used in this example. Then create a field to track number of widgets and type of widget.
Step 2: Create N:1 Relationship Between Widget and Account Entities. (So the Widgets are a Child Record of an Account)
Step 3: Create Summary Field on Account. (To hold how many widgets total you have!)
Step 4: Create Workflow on Widget Entity. You will want the workflow to fire on the create of a Widget as well as the change of the number of widgets.
Add a step with the type of Update Record. Select Account as the Entity to update.
If you are anything like me, you generally close the form assistant. But in this case, we want to leave the form assistant open. We should click on the Total Number of Widgets, Make the Operator Increment By, and Look for Widget and Number of Widgets. In the Default Value, we put a 0 so that if the user creates the entity and doesn’t fill it in, it doesn’t inflate the total count.
Save and Close the Workflow and Publish it.
So here is the finished product:
And if I browse to Widgets, you can see that we do in fact have 1011 widgets in this location for this customer.
So there is one more way that Workflow can make CRM work better for your customers. Attached is the workflow rule if you want to play with in your demo or testing environment.
Great post, I need to use something similar soon and the initial thinking was a plug but this is a great example of the power of workflow
PingBack from http://crmlike.com/?p=2160
After some offline feedback.... :)
The design goal of this was that an Oracle ERP system had a list of all of the widgets, but the sales reps never knew which how many widgets a customer actually owned.
The Account Entity was customized pretty heavily for the prospect, so I didn't really want to attach it to the Workflow. :) If somebody really needs the field, I am sure they can create it or I will fire up a blank VPC.
So for the scenario this demo script is for, it works well. I could see the subtraction being a pain, but with a little work, I know we could it without a plugin. (And will probably start messing with it after the Fiscal year is over.)
Thanks for the post.
Your example on the power of workflows, also shows one of the weak points you have to be aware about as a developer - namely transactions in the datalayer.
We are also huge fans of workflows and have developed 100+ custom workflow activities to support custom processes, but with a bit of change in your example, it shows one big weak point in the workflows also:
1) Change the workflow to be available "On Demand"
2) Now, create 3 widgets, with 1.000 items each
3) Select the 3 widgets from the list of widgets attached to the account
4) Choose "run work" and run the Widget workflow
Now, you would expect the total on the account to be 3.000 right? ...Go have a look! :)
As a developer it is *Very important* to be aware of these weak points, so you can compensate for them in your software design, where necessary.
This problem occurs because of the async. nature of the workflow manager, combined with a lack of "Row Locking" on the SQL level when reading data.
If you create 20 widgets and try this experiment again, you will see, that each time you actually get different results, because the Workflow manager cannot guarantee that the workflows will perform SQL updates in sequence.
I could go into this further, but I guess the small 4-step experiment shows the point :)
Nice point Michael.
In CRM Dynamics then, how would you suggest doing something like this (i.e. a summary type field)?
The ability to have a field that dynamically calculates itself based on a query you design into it would be wonderful, but obviously not a feature that is currently there.