Users of Microsoft Dynamics CRM 2011 have many features they can draw on to improve their CRM experience and improve business processes. One great feature to explore is using Fetch XML in a workflow.
Let’s dig in using a real business situation.
Scenario – How to determine if a Contract’s Contract Lines have a particular Product.
Solution – Luckily Microsoft CRM 2011 provides the use of executing Fetch XML in a custom workflow. Using Fetch XML (or Query Expression) in a custom workflow allows you to set up your query to use as many relationship levels as required. The added benefit of using Fetch XML is that you can use Advance Find to set up your query and download the Fetch Statement without using any other tools.
1. Start by using the Advance Find view to set up your fetch statement.
2. Next click on the Download Fetch XML button from the ribbon and open the downloaded file to select the fetch statement.
3. Next set up your Custom Workflow using Visual Studio 2010. For brevity you can reference http://msdn.microsoft.com/en-us/library/gg328515.aspx (Create a Custom Workflow Activity)
4. In the Execute method set a string variable with your Fetch XML statement and use the Services’ RetrieveMultiple method with a FetchExpression as its parameter.
5. Register your Custom Workflow using the Plugin Registration tool.
Now you have the ability to run your Custom Workflow and validate if a Contract has Product X.
Snazzy, eh? Let us know if this tip comes in handy or need a Microsoft CRM Partner to work assist in your project.