Step by Step tutorial : Creating Workflows for SharePoint 2010 tasks (Step 4/15)

 

image_thumb_thumb

SharePoint 2010 workflow tutorial

  1. Step 1.
  2. Step 2.
  3. Step 3.
  4. Step 4.
  5. Step 5.
  6. Step 6.
  7. Step 7.
  8. Step 8.
  9. Step 9
  10. Step 10.
  11. Step 11.
  12. Step 12
  13. Step 13.
  14. Step 14.
  15. Step 15.

SharePoint 2007 workflow tutorial

  1. Step 1.
  2. Step 2.
  3. Step 3.
  4. Step 4.
  5. Step 5.
  6. Step 6.
  7. Step 7.
  8. Step 8.
  9. Step 9.
  10. Step 10.
  11. Step 11.
  12. Step 12.
  13. Step 13.
  14. Step 14.
  15. Step 15.
  16. Step 16.
  17. Step 17.

Scenario

If the expense reports requires the manager approval,  we want the manager to receive a task in his task list in order to approve/reject the expense report.

 

CreateTask activity

 

Let’s drag and drop a CreateTask activity before the askManager activity and name it approveRejectTask

image

Set its Correlation token to ApproveRejectToken and the associated ownerActivityName to ExpenseReportWorkflow:

image

 

Bind the TaskProperties property to a new member (click on he ellipsis button…):

 

image

Bind the TaskId to a new member (field): ApproveRejectTaskId.

Double click on the ApproveReject task to generate a new event handler and  store a new Guid into ApproveRejectTaskId, set the task title, and associate the task with the manager:

image

 

Remove the askManager activity.

OnTaskChange activity

Add a new OnTaskChange activity and rename it waitForApprovalRejection:

 

image

Any event coming form the task will be handled by the waitForApprovalRejection activity if we group them with the same correlation token (you ‘ll have a better understanding of the correlation token in the next tutorial).

Set the correlation token to ApproveRejectToken.

This is not enough, the event doesn’t carry the taskId : you still need to associate this activity with the taskId:

Bind the the TaskId property to an existing member: ApproveRejectTaskId.

If we consider that when the user replies, the task should complete, then we need to drag and drop a CompleteTask activity

 

CompleTask activity

 

Name it approveRejectTaskComplete.

Set the correlation token to ApproveRejectToken.

Bind the TaskId property to an existing member: ApproveRejectTaskId.

Just to make sure everything will work ok, change the Show field  setting of the Created By column the Expense Reports list to account;

image

Do this as well for the column Manager and Manager Of (list Managers).

Log in a BrianC, add an expense report and run the workflow : the workflow should have the status “In Progress” as illustrated in the next picture :

 

image

 

The workflow is actually waiting for an event  in the waitForApprovalRejection activity : the event will be trigger when a task will be edited.

In the Tasks list a task as been created and assigned to Brianc manager : Amay Albert as illustrated in the next picture :

image

When we click on the task title, the following dialog will show up

image

If we edit the task and set the task as completed (for instance).

image

The task form that shows up is the default task form; we will replace it with a customized form in a next version of this tutorial.

The workflow is not In Progress (it is not waiting anymore)

image

Source code can be downloaded here.

16 responses to “Step by Step tutorial : Creating Workflows for SharePoint 2010 tasks (Step 4/15)

  1. Hi Mr.Serge Luca,
    Think you for this tutorial wish is very clear, and we are waiting impatiently for the next steps.

    Regards

  2. Your post are really helpful,Waiting for your next post Step 5 onwards,when you are planning to post next steps of 2010 Workflow

  3. Hi Mr.Serge Luca,

    When i’m trying to import workflow solution template provided by you, i’m getting an error while creating site based on that.

    “Error

    The site template requires that the Feature {8dfaf93d-e23c-4471-9347-07368668ddaf} be installed in the farm or site collection.”

    Can you please help me with above error?

    Thanks,

  4. hello sergeluca,
    your tutorial is very interesting and easily understanding. i’m waiting for the next step.thanks a lot.

  5. hello sergeluca,
    Really good tutorial. Thank you so much.

    In this step, I got an error. When I added an expense report and the amount is larger than 1000, the workflow column showed “Error Occurred”. Something wrong must be in the IfImportantAmount branch. I am confused how the task list is associated to the workflow. In the previous steps, We never use the task list. How can the task list has one item created when a report is added and in the “In process” status? Also, I downloaded the source code and found it was not for step4.

    Can you please help me with it?

    Thanks.

  6. your tutorial is very interesting and easily understanding. i’m waiting for the next step.thanks a lot

  7. Hi. Great tutorial!!!! Thanks a lot man!!!!! I was wondering what have taken you that long to bring “Step 5”; and one year witouht replying comments. Are you OK Serge? Anyway, thanks once more man….

    • Hello 🙂 I’m ok… thank you for your message; in the coming weeks, you will understand why I didn’t provide step 5 at this time.I’ve focused mainly on SharePoint BI and SharePoint with Azure, and also on something I cannot mention here + I’ve decided to move to another company .
      But I’ve never stopped working on workflows 😉 . The next big thing (on workflow) is coming up.
      But I’m very glad that this tutorial helped so many people; don’t forget that you can switch to the 2007 version as well if needed.

Leave a comment