In July we began shipping the CRM Developer Toolkit as a part of the CRM SDK. The newest release of the Toolkit adds several new features. In this post we’re going to look at how to use one of these new features: creating and deploying workflows using the Developer Toolkit.
In This Post:
- Creating a Visual Studio Solution
- Add a CRM Workflow Activity Library
- Add a CRM Workflow Activity
- Creating your Workflow
- Deploying your Workflow
- Activating your Workflow
- Related Links
To follow the steps listed below you’re first going to need the following
- Visual Studio 2010
- The CRM Developer Toolkit. This is now a part of the Microsoft Dynamics CRM 2011 Software Development Kit (SDK) on the Microsoft Download Center.
- An On-Premise deployment with Declarative Workflows enabled. The ability to use these workflows is not supported in Online deployments. To enable Declarative Workflows, see the SDK topic: Custom XAML Workflows.
For more information see: Install or Uninstall the Developer Toolkit.
Creating a Visual Studio Solution
If you haven’t worked with the Developer Toolkit you may wish to read the following sections to familiarize yourself with it. If you already have a VS Solution ready to work with you can skip to the next section.
- Start Visual Studio, then a new Project.
- In the New Project dialog, under Installed Templates, select Visual C#->Dynamics CRM
- Create a ‘New Visual Studio Solution Template for Dynamics CRM 2011’
Figure 1 Creating a Visual Studio Solution
4. Fill in the information to connect to your CRM deployment
a. First enter the Discovery Server Name, Port and Protocol. Click Connect.
b. Enter the Username, Password and Domain. Click Log On.
c. Select the Organization, then Solution you want to connect to.
d. When you are done, click OK
Figure 2 Connecting to a CRM deployment
For more information see Create a New Developer Toolkit Project.
Add a CRM XAML Workflow Library
The next step is to add a CRM XAML Workflow Library to your Visual Studio Solution.
- From the Solution Explorer, right click the solution node, then click Add->New Project
- Under Installed Templates, select Dynamics CRM
- Create a new Dynamics CRM 2011 XAML Workflow Library
Figure 3 Adding XAML Workflow Library
For more information see: Create and Deploy XAML Workflows Using the Developer Toolkit.
Add a CRM XAML Workflow Activity
Now we just need to add the activity to our project
1. Right click the CRM XAML Workflow Activity Library you just added, then click Add->New Item
2. Under Installed Templates, click Dynamics CRM. Add a XAML Workflow Activity.
3. A window will appear asking for information about your Workflow. Fill out all the information, and when done click ‘Create’.
4. The Visual Studio Workflow Designer will new open your workflow.
Creating your Workflow
You now have all the files setup and can use the Visual Studio Workflow Designer to design your workflow. Inside the Toolbox all the CRM Activities have been added and are available for your use.
Figure 5 Using the Visual Studio Workflow Designer
For an example of a simple XAML Workflow see Create and Deploy a XAML Workflow Library.
Deploying your Workflow
When you are done creating your workflow you can deploy it to your server directly from Visual Studio.
- Right click the CrmPackage project in your solution, then click Deploy.
- Your Workflow, along with any plugins and web resources will be built and deployed to the server you are connected to.
- If you are connected to a CRM Online organization or On-Premise that has Declarative Workflows disabled, you will not be able to deploy the workflow.
See the SDK topic Custom XAML Workflows for more information
For more information see Deploy a Solution Using the Developer Toolkit.
Activating your Workflow
After deploy is complete, your workflow is in a Draft state. You can now activate it right in Visual Studio.
- If it’s not already, open the CRM Explorer window by clicking View->CRM Explorer
- You will now have a view of your deployment. Expand the first node to see a list of components on the server.
- Expand the Processes Node, and then expand the Workflow Node.
- Locate your Workflow and double click it.
- Here you can modify your workflow’s information. Note that you can’t use the CRM Workflow Designer since it was created in Visual Studio.
- When you are ready, click the Activate button at the top of the window.
- Your workflow is now active!
Figure 6 Editing and Activating a Workflow
And that’s a quick run-through on how to create workflow from Visual Studio.
Developer Toolkit for Microsoft Dynamics CRM
Generic information about the Visual Studio Workflow Designer
Chris Amert worked on the CRM developer toolkit as his developer intern project. He added support for Workflows written in Visual Studio, generating the Installer package and made various improvements to the product.