Using any version of Dynamics CRM, have you ever tried to find all processes that contain
- A certain Step in some Business Process Flow
- A Custom Workflow Activity that you have developed and you try to reuse in several Workflows
- A Dialog that contains some particular question
- An Action with an specific parameter
If so, probably you noticed that Advanced Find (an out-of-the-box CRM tool to create custom queries) is not enough.
Let’s just understand the anatomy of the processes. CRM uses internally Windows Workflow Foundation as its workflow engine, so that CRM processes are defined using XAML. So, when you create a process using the CRM UI designer, the platform translates it to XAML.
So, then, we are looking for those processes which XAML contains some text. Looking at the metadata of the Process entity, we can see there is an attribute called XAML:
Note: You can find this Metadata Browser in CodePlex, see http://dynamicsxrmtools.codeplex.com/. You can also use the CRM SDK Metadata Browser
Now the question: how do we interrogate this XAML attribute? Solution: CRM OData query
CRM exposes an OData service which can be easily consumed by external applications or even using the browser. See more information in CRM SDK. Because this service allows to access more attributes than the Advanced Find tool, we can use the next query to find the processes whose XAML contains a certain string:
https://[OrganisationName].crm[x].dynamics.com/xrmservices/2011/OrganizationData.svc/WorkflowSet?$filter=substringof(‘[String]‘,Xaml) and Type/Value eq 1
The parts marked with brackets should be replaced with your corresponding context. The last condition is just filtering the Type of process, returning only those which are the actual Definition (Value: 1).
You can also build easily this query using the tool OData Query Designer in CodePlex, see http://dynamicsxrmtools.codeplex.com/.
Let’s try it now! Out of the box there is a Business Process Flow called “Lead to Opportunity Sales Process”, which contain an step with name “Existing Contact?”:
Let’s say we want to find any process that contains that step “Existing Contact”, so we will use the next query:
https://%5BOrganisationName%5D.crm%5Bx%5D.dynamics.com/xrmservices/2011/OrganizationData.svc/WorkflowSet?$filter=substringof(‘Existing Contact‘,Xaml) and Type/Value eq 1
Just putting that query in IE, we will see the next results:
Another example. Let’s say you are using N52 Formula Manager and you want to find all processes that are using a particular Formula Genie. In our example, this formula is going to generate a Hashcode for a given contact based on its fullname. This hashcode can be used for de-duplication:
Now, I want to find all the processes that are using this formula at least in one of their steps. So I will use the next OData query:
https://%5BOrganisationName%5D.crm%5Bx%5D.dynamics.com/xrmservices/2011/OrganizationData.svc/WorkflowSet?$filter=substringof(‘uzX‘,Xaml) and Type/Value eq 1
Where “uzX” is the formula short code.
Putting that query on IE, I will get the next results:
“New Customer” is a custom process that I created to use that formula and generate a hashcode every time a new contact is created or its full name gets updated:
See below a contact sample with a hashcode (below full name attribute), which has been generated by the above process:
Reblogged this on mfonsell and commented:
How to find all the processes using your own custom activity by @ramontebar