How to update the list columns from Custom Task process InfoPath form

Introduction

When you are developing your SharePoint designer workflows with the Workflow Engine 2010 (It is possible to develop your workflow with this model in SharePoint 2013 and SharePoint Online as well, but if you want to develop SharePoint Designer workflows 2010 model for SharePoint 2013 or SharePoint Online, you have to use SharePoint Designer 2013 to connect to these environments), you may want to use Custom Task Process in order to develop your workflow in SharePoint designer and you want to collect information from user on custom InfoPath task forms.

Problem

It is not possible to update the list columns with the Task columns inside Custom Task Process in the SharePoint designer workflow.

Problem Description

If you want to update the list columns with the task columns inside a Custom Task Process, the steps should be like this:

  1. Add columns you want to collect information with, to the Task Form Fields in your custom task process
  2. In the “Change the behavior of a single task” task customization section of the custom task process, in the “When a Task Completes” section, read the data in those columns and update the current list item accordingly

Although these steps seem logical, it doesn’t work! Actually the problem is when a task completes, all of those columns are empty. In fact your added columns to the task don’t fill out with the data! They are all empty.

I tried …

First try:

The ordinary way of doing the job that I mentioned above, it doesn’t work!

Second shot:

I tried a couple of scenarios to find a nice and easy way to do this. Actually I tried adding a secondary data source in an xml file and bind it to those controls which are suggested in these articles:

http://blog-sharepoint.blogspot.ca/2009/07/summary-how-to-programmatically-update.html

https://blogs.msdn.microsoft.com/infopath/2007/03/26/submitting-to-a-sharepoint-list/

But unfortunately these methods don’t work in the “Custom Task Process” InfoPath task forms in SharePoint designer.

 

Give it another chance:

I tried to develop an Ajax method and use REST API to update the task list, but it seems there is a bug in SharePoint 2010 task list that prevents me from updating the task when it is bound to a workflow.

http://stackoverflow.com/questions/17820779/sharepoint-2010-rest-api-jquery-insert-update-delete

 

Solution

When you develop a “Custom Task Process” workflow with SharePoint designer, and you want to have custom columns in your InfoPath task form to update the main list, the only solution I could implement was to use JavaScript to update the list information from the data the user enters in the custom task InfoPath form.

Steps

Step 1 – Add columns to the “Task Form Fields” of your custom task process.

First you have to add columns to the task content type. To do so you have to add columns to the “Task Form Fields” section of your custom task process in SharePoint Designer Workflow Designer

Step 2 – Open your InfoPath task form and customize the look and feel (Optional)

This step is optional, if you want to change the look and feel of your form, you can do it by opening the InfoPath form in your SharePoint designer workflow and change the layout.

Step 3 – Develop the JavaScript

Here is the source code of the JavaScript I used for this purpose:

Important notes about this script:

  1. This is script is developed with ECMA JavaScript client side model for SharePoint 2010, if you want to use it for SharePoint 2013/ SharePoint online, there are other ways to do this as well.
  2. First I wait until the JQuery and sp.js file load to the page
  3. I attached the .blur() event to the text box and check box and bind it to my update method, it means whenever a user change the values and set the control out of the focus, the update method is called and update the task item
  4. You should have the task ID in your form to know which item you have to update in the task list
  5. I placed this JavaScript in the master page, because as you know custom task forms open in “/_layouts/WrkTaskIP.aspx” page and it is not possible to add your JavaScript in this file without modifying the 14 hive file.

By using this method, you can use columns in your custom task process InfoPath forms to update the columns of your list in the SharePoint designer Workflows. You can use this method while developing SharePoint designer workflow with the 2010 model, but you can use it on SharePoint 2013 and SharePoint online as well.

About

MCSE, PMP, With more than 12 years experience in Microsoft technologies.

View all posts by

One thought on “How to update the list columns from Custom Task process InfoPath form

  1. Hi Farshid, I think I have the exact use case you do and I was able to find an Out of the box solution (SP13, 2010 workflow). Site columns don’t work, but if you use “+New” it creates a new field in the workflow task list and that works fine.

Leave a Reply