Create and deploy XAML workflows using the Developer Toolkit
Applies To: Dynamics CRM 2013
Your solution must contain a XAML workflow library project before you can create or edit a XAML workflow library. For more information about adding a XAML workflow library project, see Create a new Developer Toolkit project.
For more information about creating custom XAML workflow assemblies, see Custom XAML workflows.
Note
Microsoft Dynamics CRM Online does not support custom XAML workflow libraries.
By default, XAML workflows are not enabled. Before you can deploy XAML workflows, you must enable them on your server. If you attempt to deploy XAML workflows for an organization that has not enabled them, you will get the following error:
This workflow cannot be created, updated or published because it was created outside the Microsoft Dynamics CRM Web application. Your organization does not allow this type of workflow.
For more information, see Enable or disable XAML workflows.
In This Topic
XAML workflow library project
Create and deploy a XAML workflow library
Edit existing CRM workflows or create new XAML workflows using the Developer Toolkit
XAML workflow library project
The XAML workflow library project provides support for implementing custom XAML workflow activities for use with your on-premises Microsoft Dynamics CRM instance. XAML workflow activities that are added to the project that are based on the CRM XAML workflow activity template accelerate the starting point for development.
Create and deploy a XAML workflow library
Use the following procedure to create and deploy a XAML workflow library.
In the XAML workflow project, right-click the XAML Workflow Project node, select Add, and then select New Item.
In Add New Item dialog box, in the Dynamics CRM group of installed templates, select the XAML Workflow Activity template.
Enter the Name of the activity and then click Add.
In the Create Process dialog box, specify a Process Name and select an entity. Then, click Create.
In the XAML Workflow Library, right-click References and select Add Reference. In the .NET tab, select System.Runtime.Serialization and then click OK.
Edit the process as needed. For an example, see Create a new XAML workflow using the Developer Toolkit.
Deploy the workflow using the steps described in Deploy a solution using the developer toolkit.
Note
When you deploy changes to a workflow that is activated you will get the following error: System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: Cannot update a published workflow definition.
You must deactivate any processes that you want to update by deploying changes.
Edit existing CRM workflows or create new XAML workflows using the Developer Toolkit
You have two options for using the Developer Toolkit to edit workflows:
Edit CRM workflows
This task is a process where you export the definition of a workflow that was typically created by using the Microsoft Dynamics CRM application workflow designer. You must add this file to an existing Developer Toolkit XAML workflow project and edit the RegisterFile.crmregister so that it will be deployed with the CRM Package project. For more information, see Edit an existing CRM workflow using the Developer Toolkit.Create new workflows
To create new workflows you will add a new item using the XAML workflow activity template. For more information, see Create a new XAML workflow using the Developer Toolkit.
Edit an existing CRM workflow using the Developer Toolkit
Use the following procedure to edit an existing Microsoft Dynamics CRM workflow.
Export an unmanaged solution that contains the workflow you want to edit.
Extract the contents of the solution and, in the Workflows folder, note the XAML file that has the name starting with the name of the process you want to edit. This file will have a name that resembles the following: <ProcessName>-<GUID value>.xaml
From your XAML workflow library project, right-click and select Add Existing. Navigate to the XAML file and add it to the solution.
Open the RegisterFile.crmregister and locate the entry for the XamlWorkflowSolution element that represents the XAML workflow project you are working in.
Add a XamlWorkflowType element that has attribute values shown in the following table.
Attribute
Value
Path
The relative path of the file
Id
The ID value of the workflow. This GUID value is appended to the name of the exported workflow file
PrimaryEntity
The logical name of the primary entity for the process.
ProcessName
The name of the process
Edit the workflow in the designer as needed.
Build the solution and deploy it by using the shortcut menu on the CRMPackage project and selecting Deploy.
Test your changes:
Locate the process that you exported and activate it.
Apply the process to an appropriate record
Verify the results that you expect.
To follow the progress of the process, refresh the form by pressing F5. Then, in the Processes area of the form navigation select Workflows. You will have to press the refresh button periodically to check the status.
It may take several minutes but you should expect to see the Status Reason value eventually change to Succeeded.
If the Status Reason remains at Waiting after several minutes, you can open the System Job and expand the Details group. If there is an error you will see the error message displayed.
Create a new XAML workflow using the Developer Toolkit
Use the following procedure to create a new XAML workflow using the Developer Toolkit. The steps begin after the procedure that is described in Create and deploy a XAML workflow library.
Before you start you must complete the steps to add Microsoft Dynamics CRM workflow activities to the toolbox:
To add Microsoft Dynamics CRM Workflow activities to the toolbox
In the View menu select Toolbox.
Right-click the General group in the toolbox and select Choose Items.
Click the System.Activities Components tab.
Click Browse, locate and select the Microsoft.Xrm.Sdk.Workflow.dll file, and then click Open. All Microsoft Dynamics CRM workflow activities will appear in the Choose Toolbox Items dialog box with a check mark next to their name.
Click OK. The Microsoft Dynamics CRM workflow activities are now visible in the General tab of the toolbox, and can be used with the designer.
The following steps describe the simple operation to set the value of the description attribute of an account.
In the XAML designer add an Argument with the properties in the following table.
Property
Value
ArgumentType
System.Collections.Generic.IDictionary<System.String, Microsoft.Xrm.Sdk.Entity>
Direction
In
Name
InputEntities
Add a second Argument with the properties in the following table.
Property
Value
ArgumentType
System.Collections.Generic.IDictionary<System.String, Microsoft.Xrm.Sdk.Entity>
Direction
In
Name
CreatedEntities
From the General area of the Toolbox drag a Workflow into the designer and set the Display Name to Workflow: Set Account Description.
Note
If you do not see Workflow in the General area of the Toolbox, verify that you have completed the steps above to add Microsoft Dynamics CRM Workflow activities to the toolbox.
From the Control Flow area of the Toolbox drag a Sequence into the workflow designer and set the Display Name to Sequence: Update Step.
From the Primitives area of the Toolbox drag an Assign step into the Sequence: Update Step. Set the properties shown in the following table.
Property
Value
Display Name
Assign: Instantiate updateEntity
To
CreatedEntities("updateEntity")
Value
New Entity("account")
Add another Assign step into the Sequence: Update Step underneath Assign: Instantiate updateEntity. Set the properties as shown in the following table.
Property
Value
Display Name
Assign: Entity ID
To
CreatedEntities("updateEntity").Id
Value
InputEntities("primaryEntity").Id
Add a third Assign step into the Sequence: Update Step underneath Assign: Entity ID. Set the properties shown in the following table.
Property
Value
Display Name
Assign: Description
To
CreatedEntities("updateEntity")("description")
Value
“Description Set by XAML Workflow”
From the General group of the Toolbox, drag an UpdateEntity activity into the Sequence: Update Step underneath Assign: Description. Set the properties shown in the following table.
Property
Value
Display Name
UpdateEntity
Entity
CreatedEntities("updateEntity")
EntityName
“account”
Your workflow should resemble the following screenshot.
Right-click the CRMPackage project and select Deploy. For more information, see Deploy a solution using the developer toolkit.
Open the solution in Microsoft Dynamics CRM and locate the process with the name that you specified in Create and deploy a XAML workflow library step 3.
Check the As an on-demand process check box and save the process. Then activate the process.
To test the process:
Open an account record and then click Run Workflow from the Process group of the Account ribbon. Select the process you created and then click OK.
To follow the progress of the process, refresh the form by pressing F5. Then, in the Processes area of the form navigation, select Workflows.
It may take several minutes but you should expect to see the Status Reason value eventually change to Succeeded.
Open the account and verify that the Description value is set to “Description Set by XAML Workflow”.
If, after several minutes the Status Reason remains at Waiting, you can click to open the system job and expand the Details group. If there is an error you will see the error message displayed.
See Also
Developer Toolkit for Microsoft Dynamics CRM 2013
Custom XAML workflows
Install or uninstall the Developer Toolkit
Developer toolkit features
Create a new Developer Toolkit project
Deploy a solution using the developer toolkit
Create a new Developer Toolkit project
Deploy a solution using the developer toolkit
Create and deploy plug-ins using the Developer Toolkit
Create and deploy workflow libraries using the Developer Toolkit
Create and deploy web resources using the Developer Toolkit