Open Workflow Initiation form after InfoPath form submit

Requirement

After users complete an InfoPath web browser form, we want the user to be redirected to the approval workflow initiation form after the InfoPath form closes. We could not use the option to start the workflow on item creation as we needed to user to select an approver or multiple approvers.

Solution

We managed to get this working by creating a page with an InfoPath form webpart and a data view web part. The InfoPath form sends a configured set of parameters to the dataview webpart upon submission. The dataview webpart is then configured with a HTTP redirect so that it opens the workflow initiation form as soon as it receives data from the InfoPath form.

Configure your InfoPath form submit rule

  1. Select your submit button -> Manage Rules
  2. Ensure that ‘Send data to web part’ is set after ‘Submit using a data connection’.

 

Configure the Form Parameters

  1. Open your InfoPath form -> File -> Form Options
  2. Under Property Promotion, add at least one property to identify each item in the list. You may add additional items if you wish to do filtering.
  3. Click on OK and Publish your form when done.

Creating a new page and add the InfoPath form and Dataview Webparts.

  1. Open SharePoint Designer 2010 -> Site Pages -> New Page.
  2. Add an InfoPath form webpart and link it to your form.
  3. Add a dataview webpart and link it to your form library.

Configure the Dataview webpart

This webpart is simply used to get data from the InfoPath form, build the URL to the workflow initiation form, and redirect the user to it. After configuring the webpart, you should set its status to hidden.

  1. Select your dataview webpart -> Options (on the ribbon) -> Add/Remove Columns
  2. I selected only the ‘Name’ column as this webpart is going to be hidden anyway.
  3. Under Parameters (on the ribbon), add your filter attribute and unique identifier. In my case, I used ‘RequestNo’ to uniquely identify each record, and ‘RecruitChoice’ as a filter.
  4. With your parameters set up, click on Manage Connections (on the ribbon).
  5. Add a new connection with action ‘Get Parameters from’.
  6. Select ‘Connect to a Web Part on this page’ -> Target Web Part: InfoPath Form Web Part
  7. Target action: Send Data To
  8. Map the parameters in the InfoPath form to the parameters you set up in the dataview webpart.
  9. Click finish

Dataview Parameters

 

Webpart Connection

The next thing you need to do is set up a filter on the Dataview Webpart.

  1. Select the Dataview Webpart -> Filter (on the ribbon)
  2. Map the promoted property from your InfoPath form (in my case it is RequestNo) to the parameter you created for the DVWP ([RequestNo])
  3. Click OK.

Modify the Dataview Webpart’s XSL template

On the same page, switch your view to Code view (if you haven’t already done so).

Look for the line that says:

<xsl:template name=”dvt_1.rowview”>

..

..

</xsl:template>

Replace its entire contents with the following code, changing the parts in blue to suit your environment and requirements.

Note: In my case, I wanted to start seperate workflows depending on whether RecruitChoice = ‘staff’ or ‘workforce’.

<xsl:template name=”dvt_1.rowview”>
<tr>
<td>
<xsl:if test=”contains($RecruitChoice, ‘staff’)”>
<meta http-equiv=”refresh” content=”0;url=http://sharepoint/_layouts/IniWrkflIP.aspx?List=c4ea0309-8025-4997-a438-1b9b2443ba8b&amp;ID={@ID}&amp;TemplateID=7d892fbe-052d-4c53-9f73-b7347c5364e5“/>
</xsl:if>
<xsl:if test=”contains($RecruitChoice, ‘workforce’)”>
<meta http-equiv=”refresh” content=”0;url=http://sharepoint/_layouts/IniWrkflIP.aspx?List=c4ea0309-8025-4997-a438-1b9b2443ba8b&amp;ID={@ID}&amp;TemplateID=253f428b-e505-4dc3-87f1-954d3a5adbfc“/>
</xsl:if>
</td>
</tr>
</xsl:template>

Save the page and test the form.

If you have configured everything correctly, save the page and open it in the browser.

Complete the form and test with the parameters you specified earlier.

Your form should automatically direct to the workflow initiation form after you click the ‘Submit’ button.

Things to note

  1. Since the URL of the workflow initiation form is hardcoded, if you globally re-republish your workflow, you will need to update the TemplateID of the workflow.

 

 

Tags: , ,

No comments yet.

Leave a Reply

%d bloggers like this: