Sue Hernandez's SharePoint Blog

SharePoint and Related Stuff

SharePoint Designer 2010 Variable Number of Approvers

I have started my first foray into really getting into SharePoint Designer 2010’s “Start Approval Process” action. 

What I needed to do was to say that X number of people listed in one list had to at any given time approve everything in another list.  Well that really can’t be totally done, it seems, using OOB SharePoint Designer, and that was my requirement – ONLY SharePoint Designer, no custom, no custom SPD Actions.

What I figured I’d do was to have an “upper limit” on the number of people who can approve – say 20.  So I had a custom list of approvers with items numbered 1 thru 20.  If the “Responsible Party” column had a person in it, it should set a task for them, but if that column was blank, it should skip it.

So I figured I’d use the “Start Approval Process” action, because of 2 big reasons – (1) I needed the tasks to run in parallel; and (2) I needed the flexibility of being able to change the emails going out.   I tried the following approaches, all which did not work:

  • One “Start Approval Process” action, with all 20 rows being referenced, figuring that if it was blank, they would skip it (nope)
    • Tried it with returning the user as Login Names
    • Tried it with returning the user as String
  • Several parallel “Start Approval Process” actions, all wrapped around an IF block to say if the field was blank, don’t run it.
    • Tried it with returning the user as Login Names
    • Tried it with returning the user as String
  • Tried hard-coding all of the “Blank” people to the system account.  Then tried the IF blocks around all actions to say if the field was a system account, don’t use it.  (Never matched)

What I finally came up with was a round-about type of procedure.

  1. Create a variable called AllApprovers
  2. FOR EACH one of the 20, did this:
    1. IF Line # x Responsible Party is not blank THEN
      1. IF variable AllApprovers did not contain Line # x Responsible Party (returned as semicolon-delimited Login names)
        1. IF variable AllApprovers was blank
          1. Set variable ApproversVariable to Line # x Responsible Party
        2. ELSE
          1. Set variable ApproversVariable equal to ApproversVariable + “;” + Line # x Responsible Party
  3. IF the variable ApproversVariable is not empty
    1. Start Approval Process and set the Approvers list to the variable AllApprovers
  4. ELSE
    1. Set the workflow to Canceled and stop the workflow.

 

Basically what seemed to be happening is that when the workflow tried to serialize, it tried to convert the Responsible Party into a person.  I kept getting “Coersion” errors.  It seems that if you set the approver list to a variable, it doesn’t try to resolve it till it actually gets to it.

– Sue –

Advertisements

One response to “SharePoint Designer 2010 Variable Number of Approvers

  1. Aaron Walsh February 15, 2012 at 4:56 pm

    Thanks for the post. I am hoping to do something similar only using sharepoint designer, and your post got me thinking. I want to have a list that has the following columns: Order#, Responsible Party (returned as semicolon-delimited Login names), and #ApproversRequired. The logic would be that the workflow reads the list in order of the Order Number. For each record create a task for each person in the Responsible Party (as there can be many in there). When the number of poeple who have approved the task equals the number Reuired in the list, it should cancel the remaining open tasks, and read the next row in the list. Repeating until all rows read (I can use our logic as I dont think I will have more then 20 rows either).

    I am hoping it is possible with only Sharepoint Designer.

    Thanks again,
    Aaron

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: