Search This Blog

Wednesday, October 26, 2011

Create a State Machine Workflow with SharePoint Designer 2010 - Part 2

Part 1 of this article is located here:
Create a State-Machine Workflow with SharePoint Designer Part 1

If you have already read part 1 of this article (and you should because part 2 won't make sense without it!) then you should be ready to construct a State-Machine workflow with SharePoint Designer 2010.

So now let's get to it!!

Open SharePoint Designer 2010 (SPD10), open your solutions site, and then click on the Workflows icon in the left pane navigation menu.  When the workflow tab appears in your design surface from the Quick Access Bar choose Reuseable Workflow.  We will create two reuseable Workflows, here is the data you need to fill out the workflow creation form:
  • Workflow 1
    • Name: Review Process Workflow
    • Description: State-Machine
    • Content Type: Review Process Library
    • Statr Options: Manual and On Item Change
  • Workflow 2:
    • Name: Review Task Workflow
    • Description: State-Machine
    • Content Type: Review Process Tasks
    • Start Options: Manual and On Item Change
Now let's edit the Review Process Workflow.  We'll start by creating 4 initiation form parameters to capture the participants of the workflow, th einitiationb paramters will be as follows:
  • Submitter
  • Compliance Officer
  • Business Manager
  • Quality Control
Here is the design for the initiation parameters:



Create 5 Steps for this workflow, here are the step names:
  • Initialize
  • Submitter
  • Compliance Officer
  • Business Manager
  • Quality Control
Here is the design for Step 1, essentially, on the First Run only, we are updating the Review Process States and Review Process Roles metadata in the Review Process Library and then creating a new task in Review Process Task:



Here is the design for Step 2.  In this step we establish our normal State-Machine Workflow pattern, which is as follows:
  • Check Three Conditions:
    • Task Status
    • Review Process Role
    • Review Process States
  • Create a new task item in the Review Process Task list with these values:
    • Content Type ID
    • Title
    • Review Process Role
    • Review Process States
    • Description
    • Workflow ID
    • Assign To
  • Create a Log entry to record the action
  • Write a Log if no conditions are met for that step

Some of the finer points:
  • Make sure the role is for the person Receiving the task
  • Use the Current Item ID as the Workflow ID
  • Use the Workflow Initiation Form parameters to assign the task to a participant 

Here is the design for Step 3.  This step, and all the additional steps, will follow the same pattern as step 2.


Here is the design for Step 4. This step will follow the same pattern as step 2.


Here is the design for Step 5. This step will follow the same pattern as step 2.


Once you have all these steps configured then save, publish, and deploy your workflow to the Task Process List.

Now for our Review Task Workflow.  This is also a very simple workflow, it's purpose is just to modify the three metadata values of the document in the Review Process Library.  By modifying these values the Review Task Workflow does two things - changes the State and starts the Review Process Library workflow (which will then create a new task based on the changed state).


Once you have all this step configured then save, publish, and deploy your workflow to the Review Task Library.

So by now you may be asking, "How does all this work?"  Let's go through a scenario to help explain:
  1. Joe User uploads a document to the Review Process Library
  2. Joe wants his document to be reviewed so he manually begins the Review Process Workflow
  3. The Initian Form of the Review Process Workflow prompts Joe User for the account information of the four Role Based Participants involved in the workflow
  4. Joe provides the acocount information and then clicks the Start button, this starts the Review Process Workflow
  5. On the First Run the Review Process Workflow initializes values and then creates an initial Submitter Task in the Review Task List
  6. The Submitter receives notification that he/she has a new review task
  7. The Submitter reviews the task and chooses to change the state by modifiying the Review Process State value and then clicks OK
  8. The Review Task Workflow modifies the state based metadata values of the document in the Task Process Library
  9. Based on the new metadata values the Review Process Workflow creates a new task in the Review Task List
  10. Another participant  receives notification that he/she has a new review task
  11. This participant reviews the task and chooses to change the state by modifiying the Review Process State value and then clicks OK
  12. Steps 8 through 11 continue to repeat until the Review Process Workflow is completed

I hope that helps!

Tom

7 comments:

Anonymous said...

Dear Tom,

thanks for posting this usefull thread. I was trying to redo this example with sharepoint designer. I have a question after you have configured, saved and published the Review Process Workflow. You describe to follow this step:
"Once you have all these steps configured then save, publish, and deploy your workflow to the Task Process List."

How do you deploy the workflow to the Task Process List? Many thanks for your help!!

regards
Jorge Luis

Tom Molskow said...

Hello Jorge,

This artcle gives a nice step through of the deploy or "publish" process options -

http://sharepointyankee.com/2010/12/11/options-for-deploying-reusable-workflows-in-sharepoint-2010/

I hope that helps!

Tom

Anonymous said...

You indicated that the Review Task Workflow should be published to the Review Process Library. Shouldn't they be the other way around?

Tom Molskow said...

Hello,

Yes, you are correct, I have updated the blog - thanks for noticing that.

Tom

Anonymous said...

On Step 1, both Update Item(s) are to update the First Run field to Yes?
Thanks,
Mario
msaaval@me.com

Anonymous said...

Hello Tom,

The Task Workflow is not updating the Values on the Review Process Library. Any idea why? I followed the same steps you indicated on your 2 articles.
Why is it necessary to Update the First Run field twice during the Initialization Step?
Any help will be greatly appreciated.
Regards,
Mario
msaaval@me.com

Tom Molskow said...

Hey Mario,

Sorry for the late reply, it's been a busy few weeks for me.

On Step 1, both Update Item(s) are to update the First Run field to Yes?

I've looked through the instructions but I'm not sure where you see the instruction to update the First Run item twice, can you post the exact comment you are referring to?

The Task Workflow is not updating the Values on the Review Process Library. Any idea why?

Do you recieve any errors? Can you post one of your tasks (images and text) so I can review it?

Thanks!

Tom