How to start a standalone workflow
In Sense/Net there are two different types of workflows: Content workflows and Standalone workflows (for more information please check the Workflow types article.). Standalone workflows do not belong to a particular place in the repository, they can be started anywhere. On this page you can learn how to start a standalone workflow using the Workflow start Portlet.
See the Workflow page for detailed information on creating and managing workflows.
In this section I will show you how to build a page that can be used to start a standalone workflow step-by-step.
Please note that the Registration workflow definition and content type should be present on the portal if you want to be able to complete the following tutorial. For more information please check the Registration workflow sample article.
1. Creating a content view for the workflow
In case of a standalone workflow you do not have to create an initial (assign) content view, but you will need a start view that contains all the fields the user should fill when he/she starts the workflow. For more information please check the initial and start view article.
Public registration is a simple standalone workflow that lets users register for the site by themselves. They provide a few initial data (name, email) and after pressing the Register button, they receive a confirmation email with a link.
To display the registration form you need to create the start view for the registration workflow type. The place and name for the view must be:
The following html contains the common field controls and other markup that you should put into the content view for the workflow start portlet to function correctly:
<%@ Control Language="C#" AutoEventWireup="true" Inherits="SenseNet.Portal.UI.SingleContentView" %> <%@ Register Assembly="SenseNet.Portal" Namespace="SenseNet.Portal.UI.Controls" TagPrefix="sn" %> <div id="InlineViewContent" runat="server" class="sn-content sn-content-inlineview"> <sn:ShortText runat="server" ID="FullName" FieldName="FullName" RenderMode="Edit" /> <sn:ShortText runat="server" ID="UserName" FieldName="UserName" RenderMode="Edit" /> <sn:ShortText runat="server" ID="Email" FieldName="Email" RenderMode="Edit" /> <sn:ShortText runat="server" ID="InitialPassword" FieldName="InitialPassword" RenderMode="Edit" /> <sn:DropDown runat="server" ID="RegistrationType" FieldName="RegistrationType" RenderMode="Edit" /> </div> <div class="sn-panel sn-buttons"> <asp:Button class="sn-submit" ID="StartWorkflow" runat="server" Text="Register" /> </div>
Note that the ID of the button that starts the workflow should be StartWorkflow. If this control is not present in the content view, the start workflow portlet will not be able to start the workflow.
The only important thing in the view above is the StartWorkflow button. The portlet will look for the button with this ID and will start the standalone workflow if the user presses the button.
2. Adding a Workflow start portlet to a page
After completing the content view above, you should create a page for starting the workflow. In this case this is a simple Portlet Page under the site root:
Switch this page to Edit mode and place a Workflow start portlet onto it (it resides in the Content operation category). The following image displays the property window of the portlet.
Edit the portlet properties and set the following values:
- Portlet title: Registration
- Confirmation content path: /Root/Sites/Default_Site/Publicregistration/Started (the portlet will redirect to this path after you pressed the Register button)
- Bind target: Current content
- Relative content selector path: Workflows
- Create relative path if not exist: true
- Relative container type name: SystemFolder
- Workflow type: RegistrationWorkflow
The binding values above indicate that the portlet is bound to a system folder named Workflows, below the current page it resides (if this folder does not exist, it will be created by the portlet when the first registration process starts). When the user starts a registration, the workflow content will be created in this folder.
The confirmation path is not compulsory; if you do not provide a value here, the user will not be redirected after pressing the button.
If you followed the steps above, users will be able to start the registration process on the page.