Question

My code worked fine with my previously built (using SP web GUI) custom document library, whereby I would add a document and on the pop-up with the field textboxes, my ItemAdded event would set a taxonomy field from the an item in the termstore.

However, after changing my setup to a one where I programmatically create the content type and fields, the code to set the taxonomy field no longer works.

The SetFieldValue in the following snippet gives an error: "ArgumentOutOfRangeException - The SPListItem being updated was not retrieved with all taxonomy fields"

var listTerms = new List<Term>();
listTerms.Add(tagTerm);
field.SetFieldValue(properties.ListItem, listTerms);
properties.ListItem.SystemUpdate();

I have checked my elements and schema files and the particular field in question is set to TaxonomyFieldTypeMulti and Mult="TRUE".

When I browse the column via SP Web GUI, it has the "AllowMultipleValues" checked.

UPDATE

So the latest error I get is associated with a missing notefield (as far as I could Google!).

So I tried the following: http://sharepointificate.blogspot.ca/2012/04/deploying-multi-select-managed-metadata.html

And Also: http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/310692d3-49f2-4c0f-b911-735f24b769b3/

I modified my schema and element files by adding the notes field for the target MM field and also added the code to attach note id on feature event.

But still I get the same error.

ANOTHER UPDATE

I am using a custom Edit Form for this document library and so maybe I am missing some special markup for the hidden notefield???

Not sure what else to check so any help appreciated.

thanks,

KS

Was it helpful?

Solution

Ok, the issue was that I did indeed need to add the note fields and also all fields MUST have a name and displayname attribute. This must be done in the elements and the schema files.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top