cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How can I compare two multiple value fields in a query?

Jump to solution

I am trying to do get the contacts that will be interested in a document:

  • On a document library, we upload documents and tag them with multiple values in a managed metadata field called Interest.
  • We have a Contacts list, in which contacts are also tagged with a managed metadata field called Interest.
  • To get the contacts who would be interested in a document, we have a workflow (that is started manually) then queries a Contacts lists and picks up the contacts that are tagged with one of the Interest values of the document.

 

This works with the attached workflow, provided the contacts have only one interest (or if the documents have only one interest), the condition then reads: If ContactInterest contains Interest or Interest contains ContactInterest.
However, this does not work if both the document has multiple themes of interest and the contacts have multiple interests.

 

Does anybody know how I can pick up the relevant contacts, if both the document and the contact has multiple values in the metadata field Interest?

Labels: (1)
Tags (1)
0 Kudos
Reply
4 Replies
Workflow Hero

Re: How can I compare two multiple value fields in a query?

Jump to solution

Just an idea: what if you would manipulate the string that comes from your multiple valued managed metadata field on your document. You could for example split it and put the different values (single) in a collection variable. Then you could run/loop through your collection checking for each "interest" item in the collection which contacts are matching.

 

That way it could work to have both fields multiple valued.

0 Kudos
Reply
Not applicable

Re: How can I compare two multiple value fields in a query?

Jump to solution

Interesting idea Glenda, thank you! I am going to try and get that to work - I need to brush up on my regular expression first I think ;-)

0 Kudos
Reply
Not applicable

Re: How can I compare two multiple value fields in a query?

Jump to solution

Yes, that is the way to go, thank you!

I have put in a regular expression, to split the values of the multiple value field and store the result in a collection variable. Then I have added a For Each looping through that collection (using an additional single line of text variable for the individual values from the collection). The original workflow comparing the field in the document to the field in the contact item now lives within that For Each loop. And it works!

ForEachInterestValueWorkflow.png

0 Kudos
Reply
Not applicable

Re: How can I compare two multiple value fields in a query?

Jump to solution

Another approach is to build up a dynamic Query. The advantage of this approach is that your workflow only has to query once and not for each contact.

  <Where>

    <Or>

      <Contains>

        <FieldRef Name="ManagedMetadataField"  />

        <Value Type="TaxonomyFieldTypeMulti">{workflowvariable:Interest1}</Value>

      </Contains>

      <Contains>

        <FieldRef Name="ManagedMetadataField"  />

        <Value Type="TaxonomyFieldTypeMulti">{workflowvariable:Interest2}</Value>

      </Contains>

    </Or>

  </Where>

Based on the Collection of Interests --> Create the above red part in your For Each loop using Build String action. Then use the below in your Query List action:

  <Where>

    <Or>

        {workflowvariable:QueryBody}

    </Or>

  </Where>

If you have any questions, you know where to find me

0 Kudos
Reply