How to create initiation form for SharePoint2010 workflow part1

In the last post, I showed you how to create a simple workflow using Visual studio. In this post, I will show you how to create a custom initiation form. The initiation form is the page that is presented each time that a person starts a workflow manually. The default initiation form is very simple, including only the name of the workflow and two buttons Start and Cancel. Here are the steps to create the custom initiation form.

1. Create the simple workflow just as I did in the last post and then add the Workflow Initiation form from visual studio

2. Add the code that is highlighted in yellow in the form mark-up page.

3.Modify the return statement for the GetInitiationData method as shown below.

private string GetInitiationData()
{
return CommentTexbox.Text;
}

4. Open you workflow designer pane, and open the log-to-history task properties.

5. Instead of typing “workflow hello world” in the History Description, you set it to InitiationData as show below

6. Deploy your solution and manually trigger the workflow by open the contextual menu(screenshot a) of the item–>Workflows–>Click the YBBEST.SharePointWorkflow.Demo – CustomWorkflow–>you will see your initiation form as below (screenshot b)

(Screenshot a)

(Screenshot b)

7. Type “Custom initiation form” in the comment textbox and start the workflow, after the workflow complete you will see the Custom initiation form in the workflow history.