Thursday, May 13, 2010

iTFA and Nintex: One click to complete task and save form

In my first post from “iTFA and Nintex” series I showed you how to open a specific iTechnology Forms Accelerator perspective from Nintex workflow. It is now time to move one step forward and complicate our life a little bit more but end up with the best possible integration of the two products.

The Goal

The goal will be to open an iTFA perspective from “My Workflow Tasks” Nintex webpart. But this is too simple, so I will add one more item to my list – when user selects an iTFA action to be able to save the form and complete the workflow task the same time. Here is the time to mention that this is a temporary work-around for the iTechnology Forms Accelerator versions up to 2.0.5. For the next major release this functionality will be included without the need of coding, so that every iTechnology Forms Accelerator and Nintex user benefit from it, not only the IT pros.

Resolution Scenario

The resolution scenario for my goal includes:

  • Create a custom content type “iTFA Nintex Task” that inherits from “Nintex Workflow Task” and will be used for Nintex approval tasks

  • Create a custom approval page and configure “iTFA Nintex Task” content type to use it

  • Add iTechnology Forms Accelerator user control in this page and pass the required parameters for it

  • Capture iTFA action and based on it execute appropriate Nintex task

Step 1 and 2

I will not stop on these two steps – how to create a content type and custom Nintex approval form and how to configure the content type to use the form. There is really good description of all this in Nintex SDK, which can be downloaded here. The SDK even includes sample code that can be used as a base for our solution.

Step 3

Now is time to add iTechnology Forms Accelerator user control to the page. As I said will use the sample code from the Nintex SDK as template, but will cut quite a lot from its functionality since all I need to show on my page is iTFA control. This means that will remove all UI and actions, and instead in Main placeholder will add the control, together with few JavaScript and CSS files references that iTFA control uses:

Note that those JS and CSS files are located in “12 Hive\TEMPLATE\LAYOUTS\itfa\xxx” and this should be considered when creating the path to them. In my case I will place the page directly under “12 Hive\TEMPLATE\LAYOUTS”, so the path looks as shown above.

To use iTFA control in my page, have to add a reference to it. It is located in “iTechnology.Forms.Clients.WebControl” assembly:

And this is all for the aspx page for now. Next – what changes are needed in the code-behind.

In my code-behind class first will check if the list is integrated with iTechnology Forms Accelerator. When a SharePoint list is integrated with iTFA, then there is a property set in its properties bag, called “IsITFAActivated” and its value should be “YES”:

As I said in the previous post, to make iTechnology Forms Accelerator show specific perspective there are 3 parameters required: List ID, List Item ID and Perspective name. List and list item IDs, are available from Nintex workflow task object. For perspective name I will add one more field in my SharePoint list. This field can be updated from Nintex workflow for example.

Besides those 3 required parameters, here I add PerspectiveType and FormID. PerspectiveType property is not required, while FormID I have to add to avoid exceptions like:
Value does not fall within the expected range.

And this all – now my custom approval page can display iTechnolgy Forms Accelerator form, and can be opened from “My Workflow Tasks” Nintex webpart.

Step 4

In my scenario I want to have 3 actions available: Approve (approve the request and save the form), Decline (reject the request and save the form) and Cancel (does nothing). So, in my iTechnology Forms Accelerator form, will add “Approval” perspective (the one that will open from my workflow) and there will add those 3 actions in actions section. Remember that if I want to add additional perspectives, the form has to be in Advanced mode. For the first 2 actions (Approve and Decline), I choose “SharePoint update” as type of action to achieve saving of the form. In “Post execute action” section I’m choosing to redirect to another perspective with name “View”. This way once the action is complete, my form will open in view mode so I can see the changes.

For Cancel action I select “No Action” option for type and again to be redirected to View perspective.

In the code-behind of my custom approval page, I have to override ActionSubmit event for iTFA user control. This way once an action is submitted, will be able to check if Nintex task has to be updated and then move on with the form.

ActionSubmit event has iTFAActionEventArgs type as event arguments and this is how will get the name of the current executed action:

And when knowing the name, the proper outcome for Nintex worklow task can be selected:

Well, this is really simple implementation and can be complicated and improved the way specific case requires it, but should give you the idea how to use iTechnology Forms Accelerator user control with Nintex workflow. Here you can download the code of iTFA / Nintex Approval Page (free registration is required).
Bookmark and Share

No comments: