0
votes

I am tasked with figuring out how to automatically reassign tasks in sharepoint 2007 designer workflow. I know that it's usually done by providing the user with a reassign option in the task completion form, but that won't work for me. Here's a brief overview of the current workflow and what I need it to be able to do.

It's actually a primary workflow and a secondary workflow. The primary checks statuses, sends emails and assigns tasks. The secondary updates the status to an appropriate level each time a task is completed. Tasks are assigned based on fields within the primary list. For example their is a PM field. That is populated with a person when a new list item is created. And the workflow assigns a task to that PM.

What I need to happen is that if at any point, someone goes in to the primary list and changes the PM, I need to reassign the applicable tasks to that new without additional user interaction.

I'm not sure how to do this. Any ideas? Thanks much!

1

1 Answers

0
votes

You did not specify where the primary workflow runs - I am assuming (and hope) it runs on this primary list.

You said that whenever a new list item is created in that list your workflow runs - all you need to do is to modify this workflow to also run when a list item is modified. When the workflow is started all you need to do is to check whether some field in your list item (e.g. a custom "MyWorkflow runs already") is already set - then you know you are running on the list item modified state.

A different approach is to create yet another workflow for the item changed event and have it change your PM in the original workflow, wherever that might be set.

The last approach is to use event receivers which would involve firing up Visual Studio and I guess is not what you want (event receivers would also monitor your item changed event).


EDIT:
How to get the task item from the task list related to the running workflow?

When you have your SPListItem you can look at all the workflows running via SPListItem.Workflows which returns you a SPWorkflowCollection. Iterating over that collection you can find your SPWorkflow. This workflow in the end has a collection of all workflow tasks via SPWorkflow.Tasks. See this MSDN documentation on SPWorkflow.

Some example doing exactly this: http://sansanwal.blogspot.com/2009/08/get-workflow-task-item-from-list-item.html

If you want to do this in a non-code solution, you can also get the task via SharePoint Designer. For that you would have to create the task yourself and save the task id in some workflow variable and later on can retrieve this task by querying the task list for this specific task id.