Pages

Monday, August 23, 2010

Using Variables in Workflows

With a hung parliament, and no immediate clarity on the future of the NBN, I feel like a change of pace. So here is a quick look at building workflows in SharePoint Designer 2010.


Tutorial: Using Variables in Workflows.

This tutorial is for those who want to build an argument by looking up a field in a created variable that is being used in the workflow.

In this example, the workflow has asked a senior manager to approve a submission, and the outcome of that approval is recorded in the workflow as the variable: "Gate 2 Decision".

Always give your variables meaningful names! It becomes a logistical nightmare in more complicated workflows dealing with fields called : variable: create 1 etc.

To build this condition start by choosing the common condition: "If any value equals value".

You will see the pre-formated argument as follows:
Then, once you have clicked on the fx symbol, the "Define Workflow Lookup" will pop-up.
New in SharePoint Designer 2010: The default data source is always "Current Item".


But for this example, we want to call the variable that is stored in the InBuilt Workflow Tasks in SharePoint. So, use the drop-down menu to change the Data Source.

Then, choose the field in the variable that was used to collect the Manager's decision. Again, when creating these items, make sure that the names are meaningful. In this case, I want the field from the variable Gate 2 Decision, named "2_Gate 2 Decision" which records the outcome of the Manager's review.


Having done that, you are asked to:
  • Choose a field from the selected list and a matching value that identifies the specific item you want from the data source.

Choose ID for the generic field, and then next you need to get more specific:
For this example, I want to set the matching value as Variable: Gate 2 Decision, from the Workflow Variables and Parameters category.
The Variable: Gate 2 Decision result will be an integer.
The Define Workflow Lookup Dialog stays open, and the Lookup for Integer Dialog pops up:

Return field as: Item Id to enable the lookup to work.

The LookUp for Integer is finished, and the value appears as:

Then when you click OK:




Finally, finding the matching value is easy, as a drop-up list with all the possible options will appear.

For this workflow, the variable options (as defined as a choice menu when the task assigned to the Manager was designed) were:
Approved - Proceed to Gate 2
Approved - Proceed to Fast Gate
Not Approved
Resubmit - More Information Required


It seems complicated, but after doing this a few times it gets easy!
Have fun with that and let me know if this was helpful.

2 comments:

  1. Just to clarify, the ID on the Define Workflow Lookup screen has a green bubble that says "Current Item ID". Specifically, this is the ID column from the Inbuilt Workflow Tasks list (which is attached to the "Current Item" in SharePoint).

    In plain English, this whole argument would be:

    "Find the Manager's decision which was collected during the process called "Gate 2 Decision" and is stored in a field called "2_Gate 2 Decision" in the Inbuilt Workflow Tasks list. To get the decision for the current project, perform a lookup on the ID column in the Inbuilt Workflow Tasks List using the "Gate 2 Decision" unique identifier (variable)."

    It's long-winded, but it works!

    ReplyDelete
  2. This is such a great way of using variables. You have do explained this concept in detail. Its really helpful to me. Thank you.
    infopath

    ReplyDelete