In this blog I want to show you how to create powerful task forms for Nintex using application pages. Later on I will add an example solution with some help functions and a mechanism to use user controls as the forms. (Update: You can find the example solution here.)
Well, because you want more. Nintex workflow already supports InfoPath or Nintex Forms, but in my opinion tools like this will always have limits the moment you want something more than just editing and validating user input. Sometimes you just want the flexibility of ASP.Net. There is an example of a custom task from in the Nintex SDK. I stripped that example, so that I can use my own forms and handling of tasks. The way this works is that if you want to use a custom application page to handle a Nintex task, you create a content type based on the Nintex Content Types, associate this content type with an custom application page, and to use this in the workflow set the content type of one of the Request actions in the Nintex Workflow.
Step 1 – Create the custom content type
Go to site settings and add the content type. See image for the correct settings.
Figure 1 – Create the Nintex content type
Step 2 – Create the application page
An example solution will be added to the blog later on. Add an application page to a SharePoint solution, reference the Nintex assemblies and inherit the page from ‘Nintex.Workflow.ServerControls.NintexLayoutsBase’. Runtime two parameters will be interesting to use, these are task list id and task list item id. In my example I have a helper to use these parameters to create a context object containing objects relevant to the workflow, task, list, list item etc.
Figure 2 – Code to create the context object
Step 3 – Register application page and content type
This can now be deployed. You now know where you deployed, what the url to the application page is and what the content type’s name is. We want to let Nintex know this too, for this nwadmin.exe is used. This application can be found in the Nintex installation directory. The command is used like this:
nwadmin.exe -o SetTaskForm -siteUrl “http://yoursite/” -contentType “YourContentTypeName” -taskformUrl “_layouts/YourApplicationPage” -formType All -updateChildren Yes
Step 4 – Set the Nintex action to custom content type
Finally, we must tell the workflow action to use the custom content type so that when the user opens the task, our page is shown. Select the correct action you want to use, and set the Task content type. Publish the workflow and you’re done.
Figure 3 – Set the custom content type