Assign multiple Values to a Managed Metadata Column with COM

Hey guys,

I have a question again regarding Managed Metadata. I need to change the managed metadata of a column in a sharepoint list using the Client Object Model (with visual basic).

The research on the internet brought me to the conclusion that you need to make LabelGUID pairs for example like that:

"ThisIsATerm|d0a68a17-13e3-42b9-918b-160289cf" 

On the pages I looked so far they are using things like "TaxonomyFieldValueCollection" oder "TaxonomyFieldValue". For example:

http://stackoverflow.com/questions/10024808/sharepoint-2010-adding-multiple-values-to-a-managed-metadata-column

But those guys seem to have access to the Microsoft.SharePoint Reference, but I myself only have access to Microsoft.SharePoint.CLIENT. So for example I have other constructors than those guys and can't write a program like they do. 

Does anyone know how to assign multiple values to this sort of column only from the client side of SharePoint?

Regards

Andr

July 27th, 2015 6:32am

Hi,

According to your description, my understanding is that you want to set multiple values to managed metadata field using Client Object Model.

In my environment, I created a managed metadata field named "mymetadata" and using terms "Word","Excel","Visio", Then I used the code snippet below to add multiple values using CSOM:

 static void Main(string[] args)
        {
            ClientContext clientContext = new ClientContext("http://sp2013sps/sites/test1");
            Microsoft.SharePoint.Client.List spList = clientContext.Web.Lists.GetByTitle("custom2");
            clientContext.Load(spList);
            clientContext.ExecuteQuery();

            if (spList != null && spList.ItemCount > 0)
            {
                Microsoft.SharePoint.Client.CamlQuery camlQuery = new CamlQuery();
                camlQuery.ViewXml =
                   @"<View>  
             <ViewFields><FieldRef Name='mymetadata' /></ViewFields> 
      </View>";

                ListItemCollection listItems = spList.GetItems(camlQuery);
                clientContext.Load(listItems);
                clientContext.ExecuteQuery();
                
                foreach (var item in listItems)
                {
                    item["mymetadata"] = "1;#Excel|3839f64d-57d4-4c5b-b3d6-40bfd569d1eb;#2;#Word|e9aac055-a9ca-4f39-b45e-505974012c5c";
                    item.Update();
                    clientContext.ExecuteQuery();
                }
            }
           
        }

Thanks

Best Regards

Free Windows Admin Tool Kit Click here and download it now
July 28th, 2015 2:40am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics