Custom XAML workflows

 

Applies To: Dynamics CRM 2013

Microsoft Dynamics CRM 2013 on-premises supports the ability to create custom XAML workflows. Custom XAML workflows, also called declarative workflows, allow you to harness the power of Windows Workflow Foundation to create reusable workflows for Microsoft Dynamics CRM. Using the Microsoft Visual Studio Workflow Designer, you can create workflows by dragging workflow activities from the toolbox onto the design surface, create variables, and set properties of these activities to implement the workflow’s functionality. You can use built-in Windows Workflow Foundation activities or the process activities that are specific to Microsoft Dynamics CRM. For information about the process activities in Microsoft Dynamics CRM, see the Activities namespace.

Tip

The Developer Toolkit for Microsoft Dynamics CRM (on-premises) provides a streamlined experience for development of custom XAML workflows. For more information, see Create and deploy XAML workflows using the Developer Toolkit.

Custom XAML workflows are not supported in Microsoft Dynamics CRM Online. This is because Microsoft Dynamics CRM workflows are not supported to run in sandbox mode, and if the custom XAML workflow contains malicious code, this can lead to data security issues.

After you have created a custom XAML workflow, you can import the XAML file into Microsoft Dynamics CRM, and use the workflow without compiling it. Moreover, you can export an existing workflow in Microsoft Dynamics CRM, edit the workflow definition (XAML) using the Microsoft Visual Studio Workflow Designer, import the XAML back in Microsoft Dynamics CRM, and then use it.

Note

The workflows that are created or modified outside of Microsoft Dynamics CRM cannot be viewed or modified in the Microsoft Dynamics CRM process designer. You can only change the status (Activate or Deactivate) of these workflows. These workflows will run in Microsoft Dynamics CRM as per the workflow definition.

Prerequisites for working with custom XAML workflows

You must use Microsoft Visual Studio to develop custom XAML workflows for Microsoft Dynamics CRM.

To work with the XAML workflows that are created or modified outside of Microsoft Dynamics CRM, make sure that:

  • Your user account has the Deployment Administrator privilege in Microsoft Dynamics CRM.

  • Declarative workflows are enabled on the Microsoft Dynamics CRM server. By default they are not enabled. To enable them, use the following procedure.

Enable or disable XAML workflows

You can use Windows PowerShell to enable or disable XAML workflows, as described here. Alternatively, you can use the Deployment Web service. For more information, see Deployment entities and deployment configuration settings to learn how to programmatically update the AllowDeclarativeWorkflows property.

Enable XAML workflows

  1. Open a Windows PowerShell command window.

  2. Add the Microsoft Dynamics CRM PowerShell snap-in:

    Add-PSSnapin Microsoft.Crm.PowerShell
    
  3. Retrieve the current setting:

    $setting = get-crmsetting customcodesettings
    
  4. Modify the current setting:

    $setting.AllowDeclarativeWorkflows="True"
    
    set-crmsetting $setting
    
  5. Verify the setting:

    get-crmsetting customcodesettings
    

Disable XAML workflows

  1. Open a Windows PowerShell command window.

  2. Add the Microsoft Dynamics CRM PowerShell snap-in:

    Add-PSSnapin Microsoft.Crm.PowerShell
    
  3. Retrieve the current setting:

    $setting = get-crmsetting customcodesettings
    
  4. Modify the current setting:

    $setting.AllowDeclarativeWorkflows=0
    
    set-crmsetting $setting
    
  5. Verify the setting:

    get-crmsetting customcodesettings
    

Using the Visual Studio Workflow Designer

Using the Visual Studio Workflow Designer, you can do the following:

  • Visually create workflows without having to write code. You can create a workflow project in Visual Studio by using the built-in Visual Studio Activity Library template, and then use a Workflow activity as the root activity.

  • Add the Microsoft Dynamics CRM workflow activities in the toolbox.

  • After a workflow project is created, you can add activities to the root activity.

  • Move activities in a workflow. Some activities, for example, the Sequence activity, can contain multiple child activities. You can create variables to hold values and references that are important to your workflow by using the variables designer.

  • Modify pre-existing workflows. In this case, workflows must first be exported from Microsoft Dynamics CRM, and can be modified in Visual Studio before being imported back into Microsoft Dynamics CRM.

See Also

Write workflows to automate business processes
Model business process flows