#SharePointProblems | Koskila.net

Solutions are worthless unless shared! Antti K. Koskela's Personal Professional Blog
>

How to fix the "The SPListItem being updated was not retrieved with all taxonomy fields" error

koskila
Reading Time 3 min
Word Count 397 words
Comments 0 comments
Rating 4 (1 votes)
View

Are you getting an error like "The SPListItem being updated was not retrieved with all taxonomy fields" when you try adding or modifying values in a TaxonomyField of a list item in SharePoint, either using the GUI or with PowerShell or even programmatically? Then read ahead, I've got a quick and dirty solution!

Reason

Table of Contents

After quick googling and some frustration, I figured out the probable reason for the issue; SharePoint went and broke the link between the internal Note-field and the actual TaxonomyField you're supposed to be using. And this causes SharePoint to return slightly confusing errors.

Term Store Management Tool

Term Store Management Tool for managing (for example) the termsets associated with your Taxonomy Fields

In my case, my app actually just got a simple JSON response like below:

{"The SPListItem being updated was not retrieved with all taxonomy fields."}

I'd see this error any time I was trying to modify or create any values of a field of type TaxonomyField. I used OfficeDev.PnP's TaxonomyExtensions to achieve this, but also tried the "normal" CSOM libraries - and the result was always the same. No amount of ctx.Load(item) -calls would help ;)

Like so many times with SharePoint, the solution's simple, yet frustrating.

Solution

Remove and recreate the field. The field is broken, removing and recreating it will fix it. For me, that was a no-brainer, since all of the values were set programmatically anyway. It was easy to just restore everything by running my code again.

However, in real-life situations, this might not always work.  In that case, you can recreate the Notes field and reassociate it to the TaxonomyField. The code I borrowed below is for On-Premises, but the concept should work for SharePoint Online, too:

private void MapManagedMetadataField(Guid fieldId, Guid noteFieldId, SPSite site, string sTermStore, string sTermGroup, string sTermSet)
{
    if (site.RootWeb.Fields.Contains(fieldId))
    {
        TaxonomySession session = new TaxonomySession(site);
 
        if (session.TermStores.Count != 0)
        {
            var termStore = session.TermStores[sTermStore];
            var group = GetByName(termStore.Groups, sTermGroup);
            var termSet = group.TermSets[sTermSet];
            TaxonomyField field = site.RootWeb.Fields[fieldId] as TaxonomyField;
 
            // Set Manage Metadata's Text field to Note field
            field.TextField = noteFieldId;
 
            // Connect to MMS
            field.SspId = termSet.TermStore.Id;
            field.TermSetId = termSet.Id;
            field.TargetTemplate = string.Empty;
            field.AnchorId = Guid.Empty;
            field.Update();
        }
    }
}

See these blog posts for more details.

Comments

Interactive comments not implemented yet. Showing legacy comments migrated from WordPress.