Beginning with SharePoint 2013 workflows are fully declarative irrespective of whether they are designed using SharePoint Designer or Visual Studio. Declarative indicates that no longer the workflows are authored in code and then compiled into managed assemblies.
Instead workflows are described in Extensible Application Markup Language (XAML) and interpreted at the execution time for activities and sequences. Being the native building blocks, XAML representation of workflows comes real handy for developers in situations like below:
- Advanced debugging of workflow
- Copy of workflow between sites with some modification
- Integrating workflow in SharePoint app where workflow is not necessarily attached to any list within the app.
However while working with SharePoint Designer 2013 there is no direct method to export the workflow XAML and it is not intuitive. In this article we will explore one undocumented method to export a workflow in its XAML form.
The Process
Launch the SharePoint Designer 2013 and connect to a SharePoint 2013 site. The site can belong to On Premise SharePoint 2013 installation or to Office 365. Once connected select an already existing workflow or create a new workflow.
Figure 1: Select a Workflow
Next save the workflow as template by clicking on the “Save as Template” button in the ribbon. This will save the workflow as WSP package and save in the Site Assets library under the current site. The file will be saved by the same name as that of the workflow.
Figure 2: Save as template
Open the site in the browser and select “Site contents” from under Settings icon. Then select Site Assets from the app list. You should be able to find the WSP file in there.
Figure 3: Workflow WSP file in Site Assets
Download a copy of the file to your local desktop. Then change the extension of the file from WSP to CAB. This will change the file icon to that of a zip file. Extract the file using Winzip or WinRAR. Navigate within the extracted folder and you will find a folder structure similar to as shown below:
Figure 4: Workflow.xaml location
You will find the workflow.xaml file in the location as shown in the picture Figure 4. You can open up the XAML file in any regular XML editor for review and update.
Figure 5: Workflow.XAML
Happy coding!!