This is the second Blog post in the BLOG describing how to use workflows together with a product catalog.
This blog post will describe how to move a workflow from one environment over to another. This is resolved by exporting the workflow as a template in one environment, and importing the workflow as a solution in the other environment. Such a move is highly useful in the scenarios where workflows are created in a test environment and moved over to a production environment when it's finished. In this example I will be using workflows together with a Products list in a Product catalog site collection
The setup is as follows:
The Test server and Prod server are identical with the exception of having the SPD installed on the Test server.
- It is important that the list columns are named the same in both environments, or your workflow will have problems doing lookups from the product catalog.
- Only workflows of type «reusable workflow» can be exported and used in other environments.
Blog post content:
I’m going to show you the following:
- How to create a reusable workflow.
- How to create a SharePoint solution package that contains the reusable workflow.
- How to deploy a SharePoint solution package on a server
How to create a reusable workflow.
On your test server:
Open SharePoint Designer and connect it to the site collection containing your Products list.
Then create a workflow by clicking on Workflows and Reusable Workflow. Give the workflow a name and click OK.
You can now start adding workflow steps to this workflow. See my previous blog post Create a simple workflow in SharePoint Designer that reads from, and writes to the Products list in SharePoint 2013 for details on how to do this.
That workflow reads the Title column from the Products list, modifies it, and writes it back to the Products list.
How to create a SharePoint solution package that contains the reusable workflow.
In order to use this workflow on another server, you have to save this workflow as a SharePoint solution package (.wsp file), and then deploy it as a solution in the other server (Prod server).
To save the workflow in a .wsp format, click on Save as a template. This is only possible for workflows of type Reusable Workflow.
The .wsp file is now located in the Site Asset library in the Site Collection on your Test Server.
Go to Site Content => Site Assets and you will find your .wsp file.
Download a copy of this file to a directory on your computer.
You now have a SharePoint Solution package file (.wsp) that you can deploy on the production server.
How to deploy a SharePoint solution package on a server
On your Production server:
Copy the .wsp file from your computer to a local directory on your Prod server.
In the Site Collection containing your Products list go to Site Settings => Solutions.
Upload the .wsp file, and activate it.
Go to Site settings => Manage Site features, and activate the workflow as a feature.
Then go to your Products list => LIST ribbon => Workflow settings => Add a workflow.
On the Add a Workflow page, from the list in Select a workflow template, select your workflow.
Give it a name and click Next.
The workflow is now listed among workflows to be used for this Products list.
The workflow can now be used.
To start the workflow, select an item in the Products list, activate the ITEMS ribbon, and select Workflows.
In the workflow page click on the workflow name to start the workflow.
To verify that this workflow has been run, return to the workflow page by selecting the same item, activating the ITEMS ribbon and selecting the Workflows button.
The workflow will be listed either under Running Workflows or Completed workflows.
Click on the instance of the workflow to see log details. The workflow has ended when it is in the Completed workflows section.
To view the final result, go back to the Products list and verify that the value in the site column Title has changed.