Posted on July 5th, 2015
In this post, you will learn how to develop Initiation form in Visual Studio 2013 workflows.
Please check my previous blog post, step1 and step 2 on how to create a list workflow.
We are sharing on workflows in SharePoint 2013 and Office 365 using Visual Studio 2013. These apply to both on-premises and online. All these blog posts based on SharePoint hosted add-ins(apps).
Initiation form is used to enter values by end users who are starting the workflow manually.
For example, if your users want to add their manager name for the approval or enter some values that will used for each workflow instance that will be running. One of the prerequisites for this forms is you have to run the workflow manually. If your workflow is started automatically when the item added or updated then, initiations forms may not be the right choice. You need to look at the association form to implement or to take the configuration values for the workflows.
The below figure shows the existing Change Management Approval workflow that is running on "Change Requests" list. We will add Initiation form to the one of the existing workflow.
To add an Initiation form to the workflow, you need to select workflow then click on Add, New Item and select the Workflow Initiation form shown in the below figure.
Note: If you try to add the initiation form from the project it will not be available, it will be available in the context of workflow only.
Once the form added, the project shows as below figure where the form gets added to the Pages module by default.
You can ignore the comments from line 12 to 16 in the below snippet that are getting added in the form.
Line 27 to 36 represents the controls within the form.
Line 58 to 75 represents the object that will have values of the initiation form control.
I have modified the above code to below one to meet my requirements. Here we had only one text box to enter the data and modified the wfParams object below according to the text box control we have.
In this workflow, we will use below workflow activities on how to develop initiation form in workflows using Visual Studio 2013.
To capture the workflow parameters we can use the arguments in the workflow. Here "strArg" should match the parameter I am using in the above code snippet.
To capture the argument value you can use the Workflow to History activity. Please see below image for the configuration.
Right-click on the project and click on deploy. Once we deploy it, add an item in the Change Requests list and start the workflow manually.Once you start it, will open initiation form and enter some text "Initiation Form demo" in the text box.
Now go to workflow status page to see the history info we have written in the Initiation form. Please see below screen.
You can download the complete source code from the link below.
P.S. You can use the chapters below to jump to different section of the video.
In this post you have learned how to add an Initiation form in SharePoint 2013 or Office 365 workflows in Visual Studio 2013 workflows.
Devendra Velegandla is a five-time recipient of Microsoft's Most Valuable Professional (MVP) award (2014-2019) for Office Apps and Services, Office Servers and Services MVP and SharePoint Server. He received the MCC award for his contributions in Microsoft MSDN/TechNet forums. He loves sharing articles, videos, and tutorial on SharePoint and Office 365.