I'm on a solution where I create a term with some subterms in the termstore. After that I create a sitecolumn and a listcolumn. When setting a value to the listcolumns with
taxField.SetFieldValue(item, term, language);
taxonomyfied I get an argumentexception.
Microsoft.SharePoint.SPFieldValidationException: The given guid does not exist in the term store
The term is filled correctly and has the same guid as the element in the termstore (checked it with powershell).
What can I do to fill the newly created taxonomyfield or get around the excpetion.
[Update] It works with
taxField.SetFieldValue(item, term, language);
and the solution Stefan Bauer underneath this post. The problem is anywhere else (if you want to know read comments underneath stefan bauers post)
[Update #2] The problem was the taxonomy hidden list in the site. It was not up to date since I deleted a the field in the sitecolumns. Stefan Bauer pointed to his blogpost where the solution is first: Update your sharepoint and second: try TaxonomySession.SyncHiddenList(SPSite). Blogpost: http://www.n8d.at/blog/sharepoint-2010/anatomy-of-managed-metadata-fields/