Share via


Custom XAML workflows

 

Applies To: Dynamics 365 (online), Dynamics 365 (on-premises), Dynamics CRM 2016, Dynamics CRM Online

Microsoft Dynamics 365 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 365. 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 365. For information about the process activities in Microsoft Dynamics 365, see the Activities namespace.

Custom XAML workflows are not supported in Microsoft Dynamics 365 (online). This is because Microsoft Dynamics 365 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 365, and use the workflow without compiling it. Moreover, you can export an existing workflow in Microsoft Dynamics 365, edit the workflow definition (XAML) using the Microsoft Visual Studio Workflow Designer, import the XAML back in Microsoft Dynamics 365, and then use it.

Note

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

In this topic

Prerequisites for working with custom XAML workflows

Enable or disable XAML workflows

Using the Visual Studio Workflow Designer

Prerequisites for working with custom XAML workflows

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

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

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

  • Declarative workflows are enabled on the Microsoft Dynamics 365 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 365 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 365 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 365 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 365, and can be modified in Visual Studio before being imported back into Microsoft Dynamics 365.

See Also

Automate business processes using Dynamics 365 process
Model business process flows

Microsoft Dynamics 365

© 2016 Microsoft. All rights reserved. Copyright