Inserting or Updating a Managed Metadata field using Nintex Workflow

  • 12 September 2016
  • 33 replies
  • 136 views

Badge +16

I had these notes stored from a couple of years ago - they helped me at the time with a problem I had been banging my head with for ages, but I haven't needed to use them since.  Not sure if any use to anyone, but in the process of getting all my blog posts in one place, and what better place than the Community happy.png

 

Believe it or not, this is not straight forward.  For this blog I will paint the picture.  I have a request list which uses Managed Metadata to store Business Units.  I have a list on another site which stores approved and completed items from the original request list.  On this list, the same Business Unit Managed Metadata column is used.  I tried using the "Create item in another site" action in Nintex Workflow but could not just simply map the field from one list to the other.  Instead I had to query the TaxonomyHiddenList of the target site collection to get the ID and GUID for the term.  To find the hidden taxonomy list, simply use "Lists/TaxonomyHiddenList/AllItems.aspx" on the end of your URL after the site collection.

 

There can be multiple terms for the same value in the TaxonomyHiddenList (if it exists in a few of the term stores), so you need to be able to pass the IdForTerm in when querying the list which is achieved by using a regular expression action.

 

Firstly I use the Set Variable action to store the value from the managed metadata field in the original list into a variable.  In this example I called it vTextBusinessUnitMM

Then I used a Regular expression action to find the "IdForTerm".  The configuration below changes the variable value above to the format of the IdForTerm and stores it in the same variable.

 

 Then I use Query list to query the TaxonomyHiddenList of the target site to get the ID and the IdForTerm.  I store the returned values in variables.

Finally I use the Build String action to format the values returned:  ID;#Value|IdForTerm.  This is what needs to be passed to the destination site when inserting or updating an item with Managed Metadata field.

 


33 replies

Userlevel 3
Badge +9

What does the data in your variable vTextBusinessUnitMM look like before you run the RegEx?  I'm using SharePoint 2013 (it appears you're using 2010), and when I get the value from my MM column, it doesn't contain the IDforTerm information.  Is this a a change between 2010 and 2013?

Badge +16

Let me test on 2013 and let you know.

Badge +16

OK so i have had a play in 2013 to see how to do this.  For the test i had the following set up:

  • Site 1:  List with title field and managed metadata field (term set Organisation) called "Business Area"
  • Site 2:  List with title field and managed metadata field (term set Organisation) called "Organisation"

Requirement:

  • to have a workflow on site 1 list that would enter same term into site 2 list

The above works for 2010.  Here is what I did for 2013:

  1. workflow on site 1 list
  2. query TaxonomyHiddenList site 1 for "IdForTerm" (vTextIdForTerm) and "Title" (vTextTermTitle) where "Term" is value in list
  3. query TaxonomyHiddenList site 2 for "ID" (vIDDestinationTerm) where "IdForTerm" = vTextIdForTerm
  4. Build string vIDDestinationTerm;#vTextTermTitle|vTextIdForTerm (vTextUpdateTermValue)
  5. Create item in another site and use vTextUpdateTermValue
Badge +3

your solution works only if you have unique labels for terms but it is almost never the case in all farms. What if have multiple terms "terms" in multiple termsets ? How do I get the GUID of the term if I have only the label (stored in the field and accessible with nintex workflow) ?

Badge +16

can you leverage full path?  and use that to compare in taxonomyhiddenlist?

Badge +3

Cassy,

Even if I can do that imagine I've the following :

Countries

    France

    Switzerland

    Sweden

    ...

Keywords

   France

   Sweden

   ...

Considering taxonomy HiddenList is used for the whole site collection, if I have a Field pointing to Coutries and another pointing to Keywords, I'll have the same path, same title etc. in the TaxonomyHiddenList for 2 différents terms.

Badge +3

if I want to update an item from a site A to a Site B with managed metadata fields, in source field values I get something like :

"ID;Term"

my solution is :

the ID is corresponding to the ID in the TaxonomyHiddenList, instead of querying this list with the label i'll query it with the ID to get the GUID of the term. The ID is unique in the sitecollection, the Guid is unique in the whole Farm.

Then the update is done via webservice on 2 Fields "MyFieldName" + the associated hidden note Field StaticName.

I get the staticName calling webmethod "getlist" in list.asmx and querying XML result.

I can post more here or create a blog post if necessary but Nintex should really provide an action to update an item in another site or to get ManagedMetadata Guids easily.

If I use Update Item and pass in a variable containing the GUID, it doesn't work. I get the following error

"The workflow could not update the item, possibly because one or more columns for the item require a different type of information."

But if I pass in the GUID directly rather than stored in a variable, it does work. 

Any ideas why?

vs.

Badge +16

are you sure your variable "txtIdForTerm" has the same value as what you are entering directly?

Yes. I logged it to the Workflow history to make sure.

Badge +3

Is it in principle possible to set Multivalue Managed Metadata Columns with NINTEX Workflow?

Badge +9

Hi Cassy Freeman

My experience.

Using SP 2010, I was able using only ID;#Value to ADD the managed metadata to a NEW column using a Call Web Service Action (Not Update Item, not Set Field Value)

I was not able to UPDATE this target column, even if I remove the value from this target column.

In your scenario, do you update also your target column?

I begin to understand why there is no such action ...

Regards,

Christophe

Badge +16

Hi ‌ - it was a long time ago now I am struggling to remember but I believe I was adding not updating.

Badge +9

Thanks for your feedback. I did not find anybody able to update a managed metadata with Nintex or SharePoint Designer.

Badge +1

My colleague and I were able to figure this out a bit easier. In the action that creates the item in the destination we simply used this syntax:

-1;#[MMfield_0]

or example if your Managed Metadata field is called 'DocType' it would be:

-1;#DocType_0

I couldn't really tell you why it works but it does! The DocType_0 will be in the format TermLabel|TermGuid. I don't get the -1 but it makes the magic happen.

Badge +9

Hi ‌,

Does it also work for Updating the Managed Metadata?

Badge +1

That is what I am using it for. Creating and updating. Haven't figured out how to null out an existing field yet but haven't really tried b/c my fields are required anyway so far. It saved me about 16 steps of workflow building soap responses and whatnot.

Badge +9

Hi,

Where do you set -1;#DocType_0 ?

I have tried in a Build String Action without success.

Thanks,

Badge +1

I've used it in a couple of places but for example I put it directly in an O365/Nintex action to create an item in another site collection. Rather than select a variable or build a string first I just put it directly into that action and shockingly it worked.

Badge +9

That is what I feared, I cannot select this Item_0 as it is not available in the list of item 😞 on premise 2010

Or maybe I need to create one?

Badge +5

In your Query, is the List ID the ID of the TaxonomyHiddenList?  If yes, how did you get the ID?

<Query>

  <Lists>

    <List ID="{0x0100F91D8395C2F2A34EB7D163EFA6D2C762}" />

  </Lists>

<ViewFields>

<FieldRef Name="IdForTerm"/>

<FieldRef Name="ID"/>

</ViewFields>

<Where>

<Eq>

<FieidRef Name="IdForTerm"/>

<Value Type="Text">{WorkflowVariable:vDocCategoryValue_txt}</Value>

</Eq>

</Where>

</Query>

Badge +16

Can you navigate to the taxonomyhiddenlist and go list settings - the ID is in the URL.

Badge +5

That worked! Thank you.

Badge +5

Cassy,

How can you get the List ID of the TaxonomyHiddenList via workflow?

Regards,

Ken

Badge +16

You could use web service call _vti_bin/lists.asmx > GetList supply in "TaxonomyHiddenList" and get ID from result?

Reply