Thursday, September 09, 2010

.NET forms integration within the Sharepoint workflow


This article explains you how to get data into the Workflow from “Custom User Forms.” It turns out that SharePoint allows developers to prompt the administrators and users for information at several stages along the workflow:.

When is the workflow done connected to a SharePoint List or Document Library. This is by building and attaching aSharePoint Association Form which allows the Administrator, or a user, who connects the workflow to a SharePoint List, to set “default” values and behavior for the workflow.

Just workflow is before the prompt the user started, which gives the developer an opportunity to for information that might be needed at the start of the workflow and/or give the user an opportunity to override the default values defined via the Association Form. This is done by providing the user with a custom Instantiation/Initiation form

At running anytime during a workflow, by providing a Modification form

By assigning users Tasks (think” Outlook Tasks”), using Task-Edit forms

This workshop will focus on the Instantiation or Initiation form. The SharePoint documentation and API refers to this form by both names, but for this workshop I will refer to it as the Instantiation form. Here we are creating the initiation page

Here we are creating the custom ASPX form as the initiation page, when user invoke the instance of the workflow then first he will see that form. After submission of this form workflow will be triggered

1.How we can refer to the back end assembly/dll in the ASPX. Inherits from the NameSpace

+ BackEnd Code

<%@ Page Language="C#" EnableSessionState="True" EnableViewState="true" ValidateRequest="false" Inherits="AmitKumar.F.V.Workflows..

PublishToLibrary.Instantiation" %>

2. Where we create our design.

<asp:panel id="pnlContent" runat="server" visible="true">

<wssuc:InputFormSection Title="Product Line" Description="" runat="server">


<wssuc:InputFormControl runat="server" LabelText="" >


<%--This is your form area, here you can create your form design--%>






3. How we get the workflow properties in the ASPX form.

<input type="hidden" name="WorkflowDefinition" value='<% SPHttpUtility.NoEncode(SPHttpUtility.HtmlEncode(Request.Form["WorkflowDefinition"]),Response.Output); %>'/>

<input type="hidden" name="WorkflowName" value='<% SPHttpUtility.NoEncode(SPHttpUtility.HtmlEncode(Request.Form["WorkflowName"]),Response.Output); %>'/>

<input type="hidden" name="AddToStatusMenu" value='<% SPHttpUtility.NoEncode(SPHttpUtility.HtmlEncode(Request.Form["AddToStatusMenu"]),Response.Output); %>'/>

<input type="hidden" name="AllowManual" value='<% SPHttpUtility.NoEncode(SPHttpUtility.HtmlEncode(Request.Form["AllowManual"]),Response.Output); %>'/>

<input type="hidden" name="RoleSelect" value='<% SPHttpUtility.NoEncode(SPHttpUtility.HtmlEncode(Request.Form["RoleSelect"]),Response.Output); %>'/>

<input type="hidden" name="GuidAssoc" value='<% SPHttpUtility.NoEncode(SPHttpUtility.HtmlEncode(Request.Form["GuidAssoc"]),Response.Output); %>'/>

<input type="hidden" name="SetDefault" value='<% SPHttpUtility.NoEncode(SPHttpUtility.HtmlEncode(Request.Form["SetDefault"]),Response.Output); %>'/>

<input type="hidden" name="HistoryList" value='<% SPHttpUtility.NoEncode(SPHttpUtility.HtmlEncode(Request.Form["HistoryList"]),Response.Output); %>'/>

<input type="hidden" name="TaskList" value='<% SPHttpUtility.NoEncode(SPHttpUtility.HtmlEncode(Request.Form["TaskList"]),Response.Output); %>'/>

<input type="hidden" name="UpdateLists" value='<% SPHttpUtility.NoEncode(SPHttpUtility.HtmlEncode(Request.Form["UpdateLists"]),Response.Output); %>'/>

<input type="hidden" name="AutoStartCreate" value='<% SPHttpUtility.NoEncode(SPHttpUtility.HtmlEncode(Request.Form["AutoStartCreate"]),Response.Output); %>'/>

<input type="hidden" name="AutoStartChange" value='<% SPHttpUtility.NoEncode(SPHttpUtility.HtmlEncode(Request.Form["AutoStartChange"]),Response.Output); %>'/>

<SharePoint:FormDigest ID="FormDigest1" runat="server" />

4. Inherit class.

public class Instantiation : LayoutsPageBase

5. Set Master page at the run time.

protected override void OnPreInit(EventArgs e)



this.objWeb = SPContext.Current.Web;

// Set Master page at the run time

this.MasterPageFile = objWeb.MasterUrl;


6. Check context on page load.

if (base.Context != null)


if (SPControl.GetContextWeb(base.Context) != null)




7. Custom Submit button to invoke the workflow, and pass initiation data through serialization.

public void cmdSubmit_OnClick(object sender, EventArgs e)


string RedirectUrl = this.List.DefaultViewUrl;

SPLongOperation op = new SPLongOperation(this);






this.objWeb.Site.WorkflowManager.StartWorkflow(this.ListItem, this.Association, this.InitiationDataToXml(), true);


catch (UnauthorizedAccessException ex)




catch (Exception ex)




op.End(RedirectUrl, SPRedirectFlags.Static, this.Context, null);




if (op != null)




8. Update workflow.xml file to invoke the initiation page.


Name="V Publish To Library"

Description="This workflow publishes the documents to the Varian ELibrary."



CodeBesideAssembly="AmitKumar.F.V.VPublishToLibrary, Version=, Culture=neutral, PublicKeyToken=b0d0369bcaffb497"






Sitecore® Technology MVP 2019

Featured Post

Sitecore Error Troubleshooting: Sitecore Solr Connectivity Issue:: Part-1

Sitecore Error Troubleshooting: Sitecore Solr Connectivity Issue:: Part-1 How to verify Sitecore 9.1 (IaaS and Azure PaaS) + Solr (IaaS) C...

Total Pageviews

State Counder


About Me

My photo
Based in Bangalore, INDIA, Amit is a Sitecore MVP and MCC. He has an MCA from the U.P.T.U., INDIA and holds certifications including Sitecore and SharePoint 2007/2010. He is an contributor to Sitecore/MSDN communities and Amit have experience in Sitecore, ASP.Net with C#, MVC, SharePoint, Classic ASP, VB,Macros,HTML,JavaScript,JSON,BootStrap and AngularJS.


Follow me on Twitter