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#?

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

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.

| improve this answer | |
  • Thanks for the answer. I should have mentioned C#, although I will try and translate this JS code snippet to it's C# equivalent. – alwayslearning Nov 14 '13 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 – alwayslearning Nov 14 '13 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 Nov 18 '13 at 9:04

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.