Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Note: This topic has no later version.
The workflow extensions in EPiServer CMS are based on Windows Workflow Foundation 3.5 (WF). Workflows in EPiServer will change in coming versions of the platform due to the upgrade of WF by Microsoft (in .NET 4.5). Note that from update 40 (CMS core 7.15.0), workflows are disabled by default. Refer to Activating workflows for information on how to enable them.
The process of creating a workflow in Visual Studio, deploying it to EPiServer CMS and then registering it is easy. This example will show how to create a simple workflow that assigns a task to a group of users whenever a page is created in a specific node in the site structure.
The first step will be to create the workflow project in Visual Studio.
Create a workflow DLL as follows:
Visual Studio will now create a project for you containing an empty workflow definition with a canvas that you can drag and drop workflow items to.
By default, Visual Studio has named the workflow class Workflow1. Rename and refactor your class as follows:
At this point Visual Studio has created a workflow for you, ready to compile and deploy. You can add and modify a CreateTask activity to the workflow before deploying it to the site. With the design canvas open, drag a CreateTask activity from the toolbox and drop it on the canvas between the starting and ending points of the workflow (see Developing Workflows for information on how to add the workflow items to your toolbox).
We now need to add some code to make it possible for the workflow to let the user know what page started the instance. This will also make it possible to see this page when clicking the task.
Add the following code to your class declaration in the code-behind file:
private WorkflowPageEventArgs _pageArgs;
public WorkflowPageEventArgs PageArgs
{
get { return _pageArgs; }
set { _pageArgs = value; }
}
The compiler will not recognize the WorkflowPageEventArgs type at first. To add the right using statement, right-click the WorkflowPageEventArgs declaration and select Resolve. In the drop-down menu that appears, select EPiServer.WorkflowFoundation.Activities. The correct using statement will be added to your code and the declaration will become properly highlighted to indicate that the compiler recognizes it.
Adding the correct using statement to the code-behind:
If you try to build the project at this point you will receive a compiler error letting you know that your project is missing a reference. To solve this, right-click the References node in your solution explorer and select Add Reference. Select the Browse tab and locate the EPiServer.dll file in the bin folder of your site. Click OK and build the project. The process should now complete without errors and you will receive the "Build succeeded" message in the status bar.
Before deploying the DLL file to the site you need to connect the CreateTask activity to the page that invoked it (made possible by the code previously added in the code-behind) and to add a TaskSubject for the task to make sense to the receiving user (associate the PageLink property with the invoking page).
The process of deploying your workflow to EPiServer CMS is simply copying the recently built DLL file to the bin folder of your site and register it with EPiServer CMS as follows:
The screen shot below shows a workflow definition in EPiServer CMS.
To make this workflow start automatically every time a page is created:
Last updated: Feb 23, 2015