Sitefinity CMS empowers you to extend the built-in workflow process by creating custom workflows. Using this approach you can fit the workflow to your organization's needs. The purpose of this article is to cover the process of creating custom workflows for built-in content types or custom content types derived from Sitefinity CMS content. To extend the build in workflows you can get the default ones from the Sitefinity CMS GitHub repository.
NOTE: Custom wokflows are not supported for Standard Edition license - see license comparison.
Sitefinity CMS uses 4 different workflows for its built-in content types:
Depending on the content for which you want to extend the workflow process you must edit the necessary workflow file. For the purposes of this article we will extend the AnyContentApprovalWorkflow.xamlx file and apply it to NewsItem type.
Open your Sitefinity CMS project in Visual Studio. You can either put the custom workflow file in Sitefinity CMS project itself or build it in code library project and reference it in the Sitefinity CMS project, here we will use the latter approach. Create a new code library project in your solution. Add the AnyContentApprovalWorkflow.xamlx file and set its Build Action to Embedded Resource.
In order to create a workflow activity we need to implement CodeActivity class or one of its derived classes. The activity we are going to create will check news items sent to be published, if their author field is not set the activity is going to populate it with the first and last names of the user sending the item for publish. All logic for this is added to the Execute method of the activity. This method accepts as a parameter the workflow context from which we can extract the item going through workflow and the user publishing it. Sample code bellow:
If the activities are part of the same project as the workflow file, they will be automatically added Visual Studio's toolbox for workflow activities. Open the workflow file for edit and go to ContentApproval. There you can see that the process branches depending on the active approval process for the particular content type. Choose the case in which you want to execute the custom code activity:
The workflow is now extended. The project can be build and its assembly added to the bin folder of the Sitefinity CMS project.
You can register the custom workflows through the Sitefinity CMS advanced settings. If the workflow is embedded in an assembly first you need to create a Virtual Path for it.
To create a Virtual Path go to Administration » Settings » Advanced » VirtualPathSettings »Virtual paths and create a new Virtual Path. Configure the following properties:
The application relative path you want to use for the workflow.
The embedded resource path to the XAMLX file.
E.g. Telerik.Sitefinity.Samples.Workflow.Workflows.AnyContentApprovalWorkflow.xamlx, Telerik.Sitefinity.Samples.Workflow
Save the changes
To make a content type use a custom workflow you have to set this in the Workflow configuration editor. Go to Administration » Settings » Advanced » Workflow » Workflows and find the type for which you want to use custom workflow, e.g. Telerik.Sitefinity.News.Model.NewsItem. Open this entry for edit and set the ServiceUrl property to the application relative path to the workflow file. If you have used an embedded file use the virtual path you have created for it, e.g. ~/SfSamples/AnyContentApprovalWorkflow.xamlx. Save changes and restart the website. If you have previously activated approval workflow for this item you need to deactivate it and activate a new one to use the custom workflow.
Back To Top
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important
Copyright © 2021 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.
Progress, Telerik, Ipswitch, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.
Powered by Progress Sitefinity