• vadim@workflowexcellence.com
  • Utah, United States

Nintex Workflow 2010 – Custom Initiation/Start Form

The out of the box start form for starting a Nintex Workflow looks something like this.

I’ve seen a few requests for people who want their form to look a little different. So I thought it was well worth the time to look into developing a custom start form.

To start off we’ll make a basic skeleton Visual Studio C# project with a start and cancel button.
There’s no Nintex Code and the ASP.Net form only has 2 buttons. The code behind these buttons calls into the SharePoint API.

The form inherits from Microsoft.SharePoint.WebControls.LayoutsPageBase. There are number of methods that you can override. The main ones to notice are the on_click handlers for the 2 buttons on the form.

Generally, you will have a Start Workflow and Cancel button.

protected void StartWorkflow_Click(object sender, EventArgs e){
// Optionally, add code here to perform additional steps before starting your workflow

try

{

HandleStartWorkflow();

}

catch (Exception)

{

SPUtility.TransferToErrorPage(SPHttpUtility.UrlKeyValueEncode(“Failed to Start Workflow”));

}

}



protected void Cancel_Click(object sender, EventArgs e)

{

SPUtility.Redirect(“Workflow.aspx”, SPRedirectFlags.RelativeToLayoutsPage, HttpContext.Current, Page.ClientQueryString);

}
The form HTML is quiet simple. It just contains the 2 buttons mentioned above, inside the MainPlaceHolder content node.

<asp:Content ID=”Main” ContentPlaceHolderID=”PlaceHolderMain” runat=”server”>

<asp:Button ID=”StartWorkflow” runat=”server” OnClick=”StartWorkflow_Click” Text=”Start Workflow” />

<asp:Button ID=”Cancel” runat=”server” OnClick=”Cancel_Click” Text=”Cancel” />

</asp:Content>

One of the really good features of Visual Studio 2010, is that you can right click on the project and select Package. This will generate a SharePoint Solution file (wsp) for you. Once that is done, you can right click on the project again and select Deploy. This will add the solution to SharePoint and deploy the form to the Layouts and the assembly to the GAC.

I won’t be going through the other parts of the project, like features, signing the assembly etc, as the Internet has a bunch of information about that stuff.

Download the Skeleton Start Form – Visual Studio Project

How to use the Custom Start Form

Once the form is deployed, you’ll find it in the following location on your servers:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\
My project is named NWInitForm1, so there would be a folder with that name and inside it would be the ASPX file for the form.

Now you can go to one of your lists or libraries, open your workflow in design mode and go to Workflow Settings. Scroll down to the bottom. The 2nd option from the bottom is “Form Type”. Here you should select “Custom”.
The last option is the path to the form. My form page is name NWInitForm1Page.asmx
So for the path, I put in this:

/_layouts/NWInitForm1/NWInitForm1Page.aspx

Starting a Workflow

When you go to start a workflow:

click on your workflow name (Custom Init Form Workflow in the above screenshot) and you will be provided with your custom developed start form:

Conclusion

My aim here was to show you a really simple start form. Not much coding is required. No calls to the Nintex Workflow api or the web service. All fairly straight forward.

Now that you have a skeleton project to work with, you can start adding more bits to it that you need.

You may want :
1. show item properties that the workflow is about to start on
2. show start data fields that you can enter and pass to the workflow instance
3. display the workflow visualizer
4. show a company logo
etc

Leave a Reply

Your email address will not be published. Required fields are marked *