Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

C# - SPO Update User's profile Taxonomy attribute info

$
0
0

So basically I am updating our SharePoint Online User Profiles and attempting to update a field (SPS-Location) but it keeps telling me that it is a taxonomic field and I am unable to edit it even with the search term identifier.

Any suggestions?

This code pulls all of the terms:

 TaxonomySession taxonomySession = TaxonomySession.GetTaxonomySession(uploadContext);
            TermStore termStore = taxonomySession.GetDefaultSiteCollectionTermStore();
            uploadContext.Load(termStore,
                    store => store.Name,
                    store => store.Groups.Include(
                        group => group.Name,
                        group => group.TermSets.Include(
                            termSet => termSet.Name,
                            termSet => termSet.Terms.Include(
                                term => term.Name,
                                term => term.CustomProperties
                                )
                        )
                    )
            );
            //Term test = null;
            uploadContext.ExecuteQuery();
            if (taxonomySession != null)
            {
                if (termStore != null)
                {
                    foreach (TermGroup group in termStore.Groups)
                    {
                        //Console.WriteLine("Group " + group.Name);
                        foreach (TermSet termSet in group.TermSets)
                        {
                            //Console.WriteLine("TermSet " + termSet.Name);
                            foreach (Term term in termSet.Terms)
                            {
                                if (term.Name == "Washington DC")
                                {
                                    //Console.WriteLine("Term " + term.Name + " || " + termSet.Name  );//" || " + termSet.Id);
                                    //test = term;
                                }
                                foreach (KeyValuePair<string, string> property in term.CustomProperties)
                                {
                                    //Console.WriteLine(String.Concat(property.Key, property.Value));
                                }
                            }
                        }
                    }
                }
            }
            //Console.ReadLine();

and this is the code I am trying to use to update it:

 var propertyMap = new Dictionary<string, string>();

                propertyMap.Add("e17f7ddb-c0c2-474c-80b0-aeddcaf196ce", "SPS-Location");

This code is based on this ms document





Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>