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

I found this article which describes how to insert a list item that has a field which is of type TaxonomyFieldType.

The article describes how the TaxonomyFieldType is a similar type to a lookup field, and it explains the format required for the field value.

WSSID;#VAL|GUID

The VAL and GUID I can find, what I can't find is the WSSID!

Firstly let me explain what this WSSID is. For each site collection using your term store, Sharepoint creates a hidden list. In this hidden list sharepoint stores information about the managed terms IN USE in the site collection. Its important to note that just creating the term does not mean an entry will be created in this hidden list, only when the term is assigned to an item or document, then a list entry gets created. The WSSID is the list item GUID in the hidden list.

So this creates a logical problem.

I have a populated term store. I want to create items in a list (using a script and object model), and 1 column is a term from my term store (a managed field / TaxonomyFieldType )

If the term was not used before, the WSSID does technically NOT exist, so how can I get this WSSID if the term was not assigned before?

share|improve this question
add comment

3 Answers

up vote 3 down vote accepted

The other option, if you've got the field, and the Term is to use the SetFieldValue method and it's overrides, Specifically SetFieldValue(SPListItem, Term).

This will handle all the messy WssId details for you, but it assumes you've got the Term already (or Collection of Terms).

share|improve this answer
    
I can get the Term, so this method is looking very good. If it handles the Wssid details, then it is quicker to implement than a DIY route. thanks! –  user879 Dec 22 '10 at 10:19
add comment

Did you try the static method TaxonomyField.GetWssIdsOfTerm()?

int[] wssIds = TaxonomyField.GetWssIdsOfTerm(<site>, <termStoreId>, <termSetId>,< termId>, false, 1);

Check Peter Hoplars blog post on the subject.

share|improve this answer
    
Aha, this looks very promising. I need to test how this works, thanks Anders. –  user879 Dec 21 '10 at 20:09
add comment

If you are trying the set the value but you don't have a Term object, you can use -1 as the WssId. SharePoint will automatically assign the correct WssId the the item.

share|improve this answer
add comment

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.