Workflow–How to Set Task Fields
When assigning tasks in SharePoint workflows, you may have noticed that each task that gets assigned has one field that associates it with the original list or library item where the workflow task came from. You may have noticed the “Related Content” column in a task list. It is just a hyperlink field that links you back to that original item.
This post applies to SharePoint enterprise, and SharePoint Online for Office 365 (enterprise version). This also applies to SharePoint 2010 workflows created in SharePoint 2013 or SharePoint Online. This does not apply to SharePoint 2013 workflows.
In my experience, it’s quite challenging to do any kind of filtering and reporting just based off of a hyperlink field. And web part connections won’t even work with this field, it’s just not very useful except for just as a link to click back to that item.
What if you want to have a lookup field that goes back to the original item, or other metadata information?
In this post, I’ll show you how to create other task fields and set up the workflow so that it populates those fields when each task gets created.
My document library is called Shared Documents, and the task list is Tasks. When tasks are assigned for people to approve the documents in the library, I want a field called “LookupSharedDocument” to be populated for each task.
- Create a site column called LookupSharedDocument, as a lookup field. Make it lookup to that Shared Documents library. Pick the Title column in the drop-down. We can also pull info from any other fields in that library, so put a check box next to “modified”. Click OK. You can be creative here, and check the box next to any other fields that you’d like to see listed in the task list.
- Open your site in SharePoint Designer.
- Click Workflows on the left, and create a new workflow based on the Shared Documents library. Name your workflow “test approval”.
- Add a single action to your workflow Start Approval Process.
- Click on the blue these users.
- Since it’s just a test, you can put your own name in the Participants box. In the real world, this would be the name of the person or group who will be assigned the task.
- Next to Title, click the little ellipsis […] button. Type:
- Click the Add or Change Lookup button, and pick the Title field from the current item. Click OK. I put a “1” next to Duration per task, since I only want each person to have one day to complete their task.
- Click OK on all dialog boxes until you’re back at the workflow screen.
- Click the blue word Approval. For the name, change it to Document Approval.
- On the right in the Task Form Fields section, click Choose Existing field. Click OK to the notification message.
- IMPORTANT: Be sure and click the Publish button to publish your workflow before doing the next part, because once this lookup field is added to the task form, it won’t re-generate the form, and you’ll get the error at step 15. This won’t happen with other fields besides lookup fields, though.
- Choose the LookupSharedDocument field, and click OK.
- Click Change the behavior of a single task.
- Put your cursor in the top step called Before a Task is Assigned. Add the action called Set Task Field. Note that this is NOT the same as set field in current item, and inside of this task process inside of this one step, you’ll have actions available here that aren’t available in other parts of the workflow.
- Click the blue word FIELD. Choose LookupSharedDocument.
- Click the blue word VALUE. Pick the ID field from the current item.
- Click the Publish button at the top, to publish your workflow to SharePoint.
Note: I got an error about not being able to generate the task form or something, but I clicked OK, and I was still allowed to publish the workflow. The error just means that it won’t create the new Lookup field in the task form itself. But since we don’t want people editing it, we would have removed it anyway.
- Open your task list in the browser, and modify the default view to add the two new columns for the Lookup… information.
Now in the drop-down box for a document in Shared Documents, click Workflows, and click your Test Approval workflow. Click to START the workflow. A task will immediately be assigned to you. Take a look over in the task list, and notice that the new columns now have the lookup information in them!
Now go to your Shared Documents library, and click to edit the page (of just the default view). On the ribbon, click the Insert Related List button in the Web Part Tools (Options) tab. Notice that it lets you select that tasks list!!
This is a great solution, not just for lookup fields, but for any additional task fields that need to be populated with information from the original list or library. I just recommend creating them as site columns first. In this case, we were just looking up the ID of the current item, but there could be a case where you have a field like customer code or something, that’s just a text field in the shared documents library. You’d need to create it as a site column first, before adding it to the document library. Then, when you’re at step 11, you’d be choosing that exact same site column to put in your tasks list.
Wow, thanks Laura, I think you are a bit psychic! I just had a client ask me if it was possible to do just this. Great post and as alaways very easy to follow along with. @exnav29
Thanks for this info, Laura. do you know if it is possible to add a new column directly into the task list, and then update it from within a workflow? We want to update a custom task column in a lot of workflows, so it would be a bit of work to add the field to each task form. When I tried it, the column doesn’t appear in the list of fields within Update Task Field action. I tried instead to use Update List Item but this results in the modified task being Canceled and the workflow stops. Any ideas please?
Hi Business Analyst, No, the only way I can tell is to create that column as a site column and use the method described in this post. I’ve tried many many other ways, and this is the best, cleanest way.
Hi Laura, Thanks – unfortunately this method associates the new column with the content type of the workflow task, and as we have so many of these the column couldn’t be usefully displayed in a view on the task list. (We simply want, for example, to display the manager of the Assigned To user). Thanks anyway for a very useful blog!
How about task to its sub-tasks?
Please be more specific. Are you referring to tasks that are in folders?
First of all great blog.
I’m trying to edit a reusable workflow that someone else has created with SP Designer 2010 and I can not find the window “Select Task Process Participants”(Image below step 8).
When I edit the workflow from SPD2010 and I click on the link “Start Managerial Approval” it takes me to the task information screen (like image on step 10) but I I’m not able to find “Select Task Process Participants” window.
I’m trying to add [%Current Item: Title%] to the title for about 2 days now and pulling my hair out. The original SP developer had managed to add [%Current Item: Title%] to the Task, but after him another developer somehow got rid of it. Now I’m the third person and I’m being asked to bring [%Current Item: Title%] back to the task title.
Do I have to recreate a new column? Since the task already exist can I somehow go directly to step 8 and edit the Task Title.
Hopefully you could guide me on how to accomplish that.
Your help is greatly appreciated.
It is a great post. It was so useful.
I have a query. Can we add a control in task form say Multiselection box and can we save the selected data in the same task list by creating our own column in it. Is this possible, if so please let me know the process.
Thanks in advance.
What you’re missing is just that you need to follow step 5 and click on “these users”. That’s how I got to that screenshot at step 8.
Once you’re there, you’ll be able to edit the title. No, no new column needed.
Yes, follow steps 1 and 11 with whatever kind of column you need.
I can’t use this method when I use a custom list instead of a document library. The site column is not available to select from the workflow.Any idea would be appreciated 🙂
Hello everyone.I’m new to sharepoint and i’m stucked with the following.. I have 3 lists. One list name clients, the second list is named companies and another list named Client-Submit Request. I would like whenever the client submits a request to initiate a workflow which will get the client-username, go to the client list and get the company that this client is working and finally go to the companies list and get the responsible handler of that company. I think that this question is related to your topic, if not excuse me.
Thanks in Advance
Sorry, I can’t duplicate your issue. I created a custom list, created a workflow on it, added an “Start approval process” step, and clicked the name of the approval process, and the “task form fields” is there, along with the ability to “choose existing field”.
Get it and do what with it? You can just create lookup fields that would automatically do all of this, because lookup fields will have check boxes that let you pick other fields in that list to bring across.
I’ve noticed that the Task fields are not updated with the correct values. When a document is uploaded, the workflow starts and the approval task is already assigned (also updating he Task list). At this point the uploader still haven’t updated the fields for the document. When the uploader click “Save”, only then the fields are saved. You will see in the Tasks list that the values recorded are the values before the uploader updates the document fields.
Is there a way to amend the workflow so that it reflects the correct field values? thanks
I’ve found over the years that the task process designer is more trouble than it’s worth, and I’ve stopped using it. I just use “create list item” to create the tasks, so that I have total control over what it does.
If using “create list item” to create tasks, how do you create a list item for each person/group in the assigned to field?