Thursday, January 14, 2010

Nintex My Workflow tasks webpart - Redirect to Custom InfoPath Task form

My earlier post related to a unique problem in Nintex OOTB "My Workflow Tasks" webpart. The job of this webpart is to show all Workflow Tasks assigned to the currently logged in user.

The problem occurs when InfoPath forms come into picture, since we might have a custom InfoPath task form, and the default behavior of the webpart directs the user to the Nintex OOTB task form, so it is has no provision for redirecting users to a Custom InfoPath Task form.

There are 2 possible ways to overcome this limitation:

Approach 1: in this approach I create a new custom InfoPathApproveReject.aspx form which overrides the OOTB Nintex ApproveReject.aspx Task form and hides certain section of the form like the Approve/Reject radio buttons. Check out Approach 1 here
 
Approach 2: Is modifying the existing Nintex OOTB ApproveReject.aspx task form in the 12 Hive layouts directory. The approach is to identify whether the ItemProperties contain .xml as an extension or not, so we use the following code in the ApproveReject.aspx page:

 if (this.itemProperties.Item.Name.ToString().Contains(".xml"))
   {
          string redirectUrl = this.itemProperties.Item.Web.Url + "/_layouts/FormServer.aspx?XmlLocation=" + this.itemProperties.Item.Web.Url + "/" + this.itemProperties.Item.Url.ToString() + "&OpenIn=browser";
          Response.Redirect(redirectUrl);
   }

This will work for all web applications in your SharePoint environment. If it is a custom InfoPath form in the Item Properties object, then it simply redirects the logged in user to the Custom InfoPath task form, otherwise it shows up only the OOTB Nintex task form.

Click here to download the customized version of Nintex ApproveReject.aspx form.  

NOTE: Take a back up of your existing copy of OOTB ApproveReject.aspx page from the following location C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\NINTEXWORKFLOW.

Then replace the customized version of ApproveReject.aspx page in the above mentioned location.

Test your changes:
To test the new change, you need to have a workflow enabled List/Library with a custom infopath form and Nintex OOTB My Workflow Tasks webpart on any of your site page.

Now when the task gets created it shows up in the webpart and when you click on the Item it opens up the InfoPath custom task form.

However, if you have a standard workflow on a SharePoint list/libray without InfoPath form, then you need not worry, since it would automatically open up the OOTB Nintex task form as it never found .xml within the ItemProperties object.

No comments:

Post a Comment