Export (0) Print
Expand All

Create and deploy XAML workflows using the Developer Toolkit

Applies To: Microsoft Dynamics CRM 2013, Microsoft Dynamics CRM Online

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.

noteNote
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.

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.

  1. In the XAML workflow project, right-click the XAML Workflow Project node, select Add, and then select New Item.

  2. In Add New Item dialog box, in the Dynamics CRM group of installed templates, select the XAML Workflow Activity template.

  3. Enter the Name of the activity and then click Add.

  4. In the Create Process dialog box, specify a Process Name and select an entity. Then, click Create.

  5. In the XAML Workflow Library, right-click References and select Add Reference. In the .NET tab, select System.Runtime.Serialization and then click OK.

  6. Edit the process as needed. For an example, see Create a New XAML Workflow using the Developer Toolkit.

  7. Deploy the workflow using the steps described in Deploy a solution using the developer toolkit.

noteNote
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 Microsoft CRM Workflow or Create New XAML Workflow 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 Microsoft 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 Microsoft CRM Workflow using the Developer Toolkit

Use the following procedure to edit an existing Microsoft Dynamics CRM workflow.

  1. Export an unmanaged solution that contains the workflow you want to edit.

  2. 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

  3. From your XAML workflow library project, right-click and select Add Existing. Navigate to the XAML file and add it to the solution.

  4. Open the RegisterFile.crmregister and locate the entry for the XamlWorkflowSolution element that represents the XAML workflow project you are working in.

  5. 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

  6. Edit the workflow in the designer as needed.

  7. Build the solution and deploy it by using the shortcut menu on the CRMPackage project and selecting Deploy.

  8. Test your changes:

    1. Locate the process that you exported and activate it.

    2. Apply the process to an appropriate record

    3. 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.

    4. 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.

You must also complete the steps to Add Microsoft Dynamics CRM Workflow Activities to the Toolbox.

The following procedure will have the goal to set the value of the description attribute of an account.

  1. 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

  2. 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

  3. From the General area of the Toolbox drag a Workflow into the designer and set the Display Name to Workflow: Set Account Description.

    noteNote
    If you do not see Workflow in the General area of the Toolbox, verify that you have completed the steps Add Microsoft Dynamics CRM Workflow Activities to the Toolbox.

  4. From the Control Flow area of the Toolbox drag a Sequence into the workflow designer and set the Display Name to Sequence: Update Step.

  5. 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")

  6. 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

  7. 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”

  8. 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.

    XAML Workflow

  9. Right-click the CRMPackage project and select Deploy. For more information, see Deploy a solution using the developer toolkit.

  10. 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.

  11. Check the As an on-demand process check box and save the process. Then activate the process.

  12. To test the process:

    1. 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.

    2. 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.

    3. Open the account and verify that the Description value is set to “Description Set by XAML Workflow”.

    4. 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

Microsoft Dynamics CRM 2013 and Microsoft Dynamics CRM Online
Send comments about this topic to Microsoft.
© 2014 Microsoft Corporation. All rights reserved.
Show:
© 2014 Microsoft