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

Today I suddenly received the following error when I updated a list item with a taxonomy field:

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

In central admin there is a setting that throttles the lookup return count, and Taxonomy fields are just lookups.

To fix this go to Central Administration, Manage Web Applications, select the web application, and then choose the dropdown under General Settings select Resource Throttling.

The setting for List View Lookup Threshold and raise it from the default 8. it can go up to 1000 although you are unlikely to need this many lookups.

Today I found a second reason and a 3rd reason why the same The SPListItem being updated was not retrieved with all taxonomy fields error might appear.

Solution

Option 1 – General typos

During my development I made some silly typos (happens sometimes) and my metadata field didn’t get deployed properly. The field existed but it wasn’t linked up properly. As always some typos take a lot of time to correct them.

In this case the two fields (When you deploy a taxonomy field two fields are created; A TaxonomyFieldType and a Note field). The two fields need to be linked up using the TextField property on the TaxonomyFieldType field.

The weird thing is that when there are multiple taxonomy fields on an item only one taxonomy field needs to be incorrect to get all the taxonomy fields to generate the above error.

Option 2 – List and Web ID left behind

In the definition of the Taxononmy field a List and Web Id can be found when copying the field definitions  with a tool like SharePoint Manager:

<FieldType=TaxonomyFieldTypeList={d42eb4ce-6521-4acd-983a-3ce1a44325e7}WebId=5eabab63-ca28-4bf4-a527-d5f8b4355c37

When these two properties are left behind the same unclea “The SPListItem being updated was not retrieved with all taxonomy fields” error might appear again. This seems to eb the catch all error message for taxonomy fields.

 

So how should we deploy a taxonomy field then?

In my case I wanted to create an archive list which has a couple of metadata driven fields. One for box numbers and one for Keywords.

So I first created the site columns for these two metadata fields (4 fields in total) in Visual Studio.

Then added the TaxonomyFieldType fields to my content type

Then updated my list template’s schema.xml to include the 4 fields.

Finally I used some code to link the Taxonomy fields to the TermSets

One day I might update this article to include the full code but there seem to be a few articles around that do the same. One example

Advertisements