3

CAML request returns [object Object] for a field that contains managed metadata. How does that get converted to a value that can be display on the web. For example, I know that a lookup field requires a .get_lookupValue() but I don't know how to handle a managed metadata field.

Assistance greatly appreciated.

Thanks

4

There are 2 methods to query a list/library that contains a managed metadata column:

  1. Query against Term Name
  2. Query Against WSSID

Method 1 (will look something similar to this):

 query.Query = @"<Where>
                  <Contains>
                      <FieldRef Name='" + MyTaxonomyFieldName + @"' />
                      <Value Type='Text'>" + tagName + @"</Value>
                  </Contains>
                </Where>";

Method 2:

query.Query = @"<Where>
                  <In>
                   <FieldRef LookupId='TRUE' Name='" + MyTaxonomyField + @"' />
                    <Values>
                       <Value Type='Integer'>" + tagLookupID + @"</Value>
                    </Values>
                  </In>
                 </Where>";

it is recommended to use the second method to avoid situations where the term name is used under different term groups!

  • Thanks that is helpful in building a query for a specific value. However, I'm pulling ALL the managed metadata and want to display in the html: markup += '<td>' + listItem.get_item('TaxKeyword') + '</td>'; this displays as [object Object] I need to add to the get Item() so that the assigned managed metadata valus(s) will display. – PianoMan Jun 6 '16 at 17:03
  • I believe you can get it like this: var mngMetadataColumn = item.get_item('test'); var mngMetadataColumnLabel = mngMetadataColumn.get_label(); – Ahmed Mahmoud Jun 6 '16 at 18:59
  • Ahmed, Thanks but it did not work. Would you be able to point me to some documentation stating what types of field type need to be converted and how to do it. Thanks – PianoMan Jun 6 '16 at 20:19
  • Thanks Ahmed. It appears to be a bit more complex them simply listing the contents of a text field. I will need to rethink. Again Thanks – PianoMan Jun 7 '16 at 0:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.