Hello. This is JongHwa Lim – a Program Manager from SharePoint Designer (aka. SPD) team.
Today I’d like to introduce a feature which has been enhanced a lot from SharePoint Designer 2010 and SharePoint Server 2010. It is the workflow package feature. A very common scenario for those who used this feature in SharePoint Designer 2010, was to develop one workflow in a development environment and then deploy it to a production environment. Unfortunately, the bad news was that this was supported only for reusable workflow types in SharePoint Designer 2010.
In SharePoint Designer 2013 along with SharePoint Server 2013 and Azure Workflow Service, we now support all three workflow types – list workflow, site workflow, and reusable workflow. This is superb. This means you don’t have to confine yourself only to the reusable workflow and the old story that you had to migrate your list workflows to reusable workflows for this purpose are all now gone.
An example will help tell this story much better. I will build a sample workflow and show how it can be reused in a target site.
Let’s say you are going to create a list workflow on a development environment. The workflow has two lists – Vacation list and Vacation Request list. Vacation list keeps the number of remaining vacations for all the employees and Vacation Request list is where the requestor will create a request item to request approval for vacation.
As said, we need two lists so I created two lists as below. Note that we will use the default settings for the ‘Task List’ and ‘History List’.
Now that you have the necessary lists ready, use SPD to connect to the server, click ‘List Workflow’, and then choose ‘Vacation Request’ list. You will be shown a dialog below and make sure you choose ‘SharePoint 2013 Workflow’ type after you type in the workflow name.
In the SPD canvas, you can choose text-based designer or if Visio Professional is installed you can choose the visual designer to author the workflow. In this blog, I will use the text-based designer but if you are interested in the visual designer, please refer to another blog post on the visual designer, which will be available soon.
Please add the following logic. In general, it is very straight-forward except for a couple points. It consists of five stages. Each stage’s title explains what it is for but to explain it in more detail, I’ve described them below:
The tricky parts are these lookup UIs to fetch the remaining vacation days from Vacation list or to update the Vacation list.
You can opt to turn on ‘auto start by item creation’ option if it makes more sense.
And when you publish the workflow the workflow association will be created and the status column will be made behind the scenes.
There are several ways by which you can guarantee that the target server has the necessary lists and schemas but leveraging STP package is a good practice. So let’s package Vacation list and Vacation Request list into a STP packages.
You can do this via either server UI or SPD UI as shown below.
Then, you will see the following screen where you can type in the name and choose to package the contents as well.
Note that SharePoint 2013 list workflow is not packaged together whether you choose to ‘Include Content’ or not.
And if successful, it will guide you to a place where you can download the package.
Click the link and download the package for later use.
If successful, you must have two STP packages now, one package for the Vacation Request list and another for the Vacations list (the list that contains the remaining vacation days).
To package the list workflow, go to the workflow summary page and click the ‘Save as Template’ button in the Ribbon.
The following dialog will be shown.
You can find ‘Site Assets’ library in the Navigation pane and you can find the list workflow package in it. (You may need to refresh the page to see the package.)
Use the ‘Export File’ Ribbon button to save it to the local machine.
Open the target site(or production environment) in your browser and go to ‘Site Settings’. You can find ‘List templates’ menu under ‘Web Designer Galleries’ group.
Using the ‘Upload Document’ under ‘Files’ menu, upload the two STP packages.
You can create the two lists from the deployed list templates. Go to ‘Site Contents’ in the navigation menu in the server and click ‘add an app’. You should be able to find ‘Vacation’ and ‘Vacation Request’ icons.
Create ‘Vacation’ and ‘Vacation Request’ lists using those menus.
Deploying WSP package is a bit different from deploying STP list templates. You must upload it to ‘Solutions’ library under ‘Web Designer Galleries’ group in Site Settings.
Then, you will be prompted with a dialog where you need to activate the package(solution).
After activating the solution, you will see there is a new site feature in ‘Manage site features’ under ‘Site Actions’ of Site Settings.
This is it. You can find this workflow by the name you used when you packaged it. Click the ‘Activate’ button and wait until the button changes to ‘Deactivate’ or the ‘Active’ icon is shown, which will mean that the feature is activated.
There are cases when you want to update the workflow in the target site. No problem. It is just the same as your development environment. You can find the deployed workflow correctly listed in SPD.
And it will open without any issues. You can see that the values in the summary page remain the same. And of course, the logic is preserved as well.
After you run the workflow from the server, you may find that there are two columns with the same name(workflow status column). This is a known issue. One column comes from the source server(packaged in STP) and the other column is created in the target site. Please update the list view to hide the old column.
The solution will be properly deployed as long as the target site has the necessary lists – lists that are used in the workflow logic along with the Workflow Task and Workflow History lists. But it is best to create the lists and list columns referenced in the workflow using the same list template and same field type. If there is a type mismatch, the package can fail during the feature activation time or the workflow will fail at runtime.
The site feature activation will fail.
The error message is not very detailed but if you look at the ULS log, you can find some hints like the following:
“Workflow XAML failed validation due to the following errors: Failed to create a 'ListId' from the text '$ListId:Lists/Vacation;”
But once the feature activation has failed, re-activation of the feature may fail again even after you create the necessary lists. This is because your workflow definition is deployed incompletely. You need to do the following:
This should solve the problem.
These are the known issues of workflow package.
This is indeed big improvement.
I met this issue when trying to active the feature:
Unexpected System.InvalidOperationException: System.ArgumentException: WSEventSourceGUID at Microsoft.SharePoint.WorkflowServices.WorkflowSubscriptionStorageEventReceiver.ItemAdded(SPItemEventProperties properties) at Microsoft.SharePoint.WorkflowServices.SPWorkflowPackageFeatureReceiver.FeatureActivated(SPFeatureReceiverProperties properties) at Microsoft.SharePoint.SPFeature.DoActivationCallout(Boolean fActivate, Boolean fForce) at Microsoft.SharePoint.SPFeature.Activate(SPSite siteParent, SPWeb webParent, SPFeaturePropertyCollection props, SPFeatureActivateFlags activateFlags, Boolean fForce) at Microsoft.SharePoint.SPFeatureCollection.AddInternal(SPFeatureDefinition featdef, Version version, SPFeaturePropertyCollection properties, SPFeatureActivateFlags activateFlags, Boolean fo... 5ba2f29b-0de2-c096-b988-1adcf27a6c6c
01/08/2013 10:24:13.46* w3wp.exe (0x2894) 0x2DC0 SharePoint Foundation Runtime tkau Unexpected ...rce, Boolean fMarkOnly) at Microsoft.SharePoint.SPFeatureCollection.AddInternalWithName(Guid featureId, Int32 compatibilityLevel, String featureName, Version version, SPFeaturePropertyCollection properties, SPFeatureActivateFlags activateFlags, Boolean force, Boolean fMarkOnly, SPFeatureDefinitionScope featdefScope) at Microsoft.SharePoint.WebControls.FeatureActivator.ActivateFeature(Guid featid, Int32 compatibilityLevel, SPFeatureDefinitionScope featdefScope) at Microsoft.SharePoint.WebControls.FeatureActivatorItem.ToggleFeatureActivation() at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 5ba2f29b-0de2-c096-b988-1adcf27a6c6c
Any idea about how to resolve this issue?
Thanks JongHwa Lim. This is really informative article on SPD.
I've a query here,,, In SharePoint 2013 list workflow, there is an option to save as template. But Approval workflow is not available there ( "start approval process")
So is there any way to use this in SharePoint 2013 workflow i.e. “Start Approval Process” ?