Now that SharePoint 2010 Managed Metadata (MMD) is more widely used, it is no surprise that developers would want to utilize MMD fields when using conditions and/or actions in SharePoint Designer. However, after some frustration, I realized that SharePoint Designer 2010 and Managed Metadata are not yet on cordial terms. Hopefully, Microsoft will address the limitations of MMD when used by SharePoint Designer and otherwise, in the next release of SharePoint.

In this blog, I will explain what I was attempting to do (Part 1), how I realized it wasn’t working (Part B) and what I did as a workaround (Part C):

Part 1 – Business Requirement (Problem):
I was developing a customized Approval Workflow in SharePoint Designer that routed a document to the appropriate approver based on which Process (MMD) was selected while uploading/modifying a document (essentially, a MMD tag in the upload/modification form). SharePoint would then reference a hidden Process & Process Owner list, compare the Process fields and dynamically email the Process Owner of the selected Process.

Document Library – Utilizes a customized approval workflow
Process & Process Owners List– Contains Process Owner names (people picker column) and their respective Process’.


Action: Retrieve the ‘Process Owner’ (Login Name) from the
Process Owners list where the ‘Process’ field is equal
to the Current Item’s Process field. 

This functionality works perfectly when comparing regular SharePoint Columns (not MMD), but (as explained below) the same filter fails when comparing MMD fields.

Part B – How the Problem was Identified:
At first, I was miffed as to why the appropriate Process Owner was not getting an email when they had been assigned a task. I used the following test scenario in order to narrow down the fact that MMD was indeed the culprit.

I first created two identical custom Lists:

Test 1 List
Title (text)
Grocery (text)
Store (text)
Mall (text)
Americas Site (Managed Metadata)

Test 2 List
Title (text)
Grocery (text)
Store (text)
Mall (text)
Americas Site (Managed Metadata)

Workflow 1 Scenario:
Both Lists have the word ‘Bread’ in the Grocery Column.

My Workflow was constructed to return the value (via a variable) in the Mall Column (in Test List 2) when the Grocery value was the same as the Current Item in Test List 1 (see below) and email me the stated variable.

When I ran this workflow and emailed myself the Variable, I got the expected returned Variable: Meadows

Workflow 2 Scenario:
Same as above. The only difference was that my workflow was constructed to return the value (via a variable) in the Mall Column (in Test List 2) when the Americas Site value was the same as the Current Item in Test List 1. Both were set to Littleton.

When I ran this workflow and emailed myself the Variable, I get a blank Variable.

Let me step back for a moment. Managed Metadata, when referenced by SharePoint Designer only works when the Term|GUID are used in conjunction. For more information regarding this, check out this blog. This may be one of the factors that make comparing MMD fields more difficult. That logic doesn’t necessarily make sense to me, because in theory when comparing managed metadata to the exact same piece of managed metadata, SharePoint should compare the “Term|Guid”.

In order to explore this further, I ran a test to extract both MMD variables in each list and got the following Term|GUID:

Library Process Field: Product and Process Design|e4e881f7-0b5a-4bec-94b4-68e12213e5cc
List Process Field: Product and Process Design|e4e881f7-0b5a-4bec-94b4-68e12213e5cc

Even though they are the same, I was still not able to compare them for use in my workflow. For whatever reason, SharePoint Designer does not recognize that these fields are the same.

Part C – Solution:

As I said previously, comparing two regular SharePoint columns works like a champ, so the workaround essentially involved creating a workflow on the Process Owner list (to run whenever an item is created or modified) to copy the Term|GUID from the Process MMD field into a SharePoint text column (hidden on forms). I called this column, ‘Workflow Process Comparison’.

I then created an initial action in my document library approval workflow to set a Variable: Current Item Process equal to the Current Item Process.

 

 

 

 

 

 

 

 

I then compared the Workflow Process Comparison (in the process owner list) text field to the Variable: Current Item: Current Item Process:


Action: Retrieve the ‘Process Owner’ (Login Name) from
the Process Owners list where the ‘Workflow Comparison’
field is equal to the Variable: Current Item Process.

 

By doing this, I was essentially comparing two text fields (a SharePoint column and a Variable, also text) rather than two MMD fields.  This worked like a charm!