Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question
    
Can you add terms to the field through the UI? –  Per Jakobsen Aug 18 '12 at 21:52
    
Thanks for your reply. The answer is.. no. I get "Failed to get value of the "Tags" column from the "Managed Metadata" field type control. " I can set it to a value via the column settings page but that is obviously no good. –  Perplexed Aug 20 '12 at 13:37
    
OK seems like your creation of the field fails in some way maybe check Correctly Provisioning Managed Metadata Columns –  Per Jakobsen Aug 20 '12 at 13:49
    
Actually, I need to by-pass some code and test via UI again. I am updating the question with more info. –  Perplexed Aug 20 '12 at 13:54
    
Ok having followed the link you posted, I now get the error: Invalid field name. {6936f2b0-c0b8-4bb1-909d-63373c1b39d8}. This ID matches that of the TextField in the <Customization> markup. –  Perplexed Aug 20 '12 at 15:45

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.