2

I would like to obtain the 'Tags' for each SharePoint (2010, 2013) list item (either a document in a library or an item in a list) using the Client Object Model.

I haven't found any API that let's me do that. Is it possible via the Client Object Model using C#?

2
  • What version of SharePoint are you using? 2007, 2010 or 2013? The API vary a lot Commented Nov 14, 2013 at 10:10
  • I'm looking for a solution for both SharePoint 2010 and 2013 Commented Nov 14, 2013 at 10:13

1 Answer 1

0

Yes, it's possible. You don't say if you mean C# or JavaScript. I'll assume JavaScript. Retrieve your item, and then:

var fieldValues = item.get_fieldValues();
var enumerator = fieldValues.taxonomyField.getEnumerator();
while (enumerator.moveNext()) {
    var term = enumerator.get_current();
    var termLabel = term.get_label();
    var termId = term.get_termGuid();
}

Note that if it's a single value taxonomy field, you don't need the enumerator. E.g.

var termLabel = fieldValues.taxonomyField.get_label();

Further note - you'll need to make sure your code loads the SP.Taxonomy.js file.

3
  • Thanks for the answer. I should have mentioned C#, although I will try and translate this JS code snippet to it's C# equivalent. Commented Nov 14, 2013 at 12:07
  • Is this part of the Client Object Model? I do not find any 'taxonomyField' member on the 'ListItem' type.ListItem.FieldValues is a Dictionary Commented Nov 14, 2013 at 12:43
  • 'taxonomyField' is just the internal name of your Taxonomy field. If you've called it 'thingy' then it would be 'fieldValue.thingy ...'. Similar code should work in C#
    – Andy Burns
    Commented Nov 18, 2013 at 9:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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