Wednesday, December 21, 2011

SharePoint 2010 - why should you consider creating termsets with code


Creating termsets in 2010 is very simple.
Create an csv file with the correct format (Term Set Name,Term Set Description,LCID,Available for Tagging,Term Description,Level 1 Term,Level 2 Term,Level 3 Term,Level 4 Term,Level 5 Term,Level 6 Term,Level 7 Term,GUID)
I really like this new feature and the OOTB control that you can use with termsets.

But if you are not very careful when you use termsets in your project if you are planning to use SharePoint backup/restore as a deployment mechanism. as these termsets are not part of content database, you will need to manually create the termset on the destination server.
Now...the problem is, SharePoint assign a GUID (oooh yes) to each term when you create termsets sing csv file impoerts. When you create the same termsets on your destination server, SharePoint will assign a different set of GUIDs. This means the data won't identify the terms and you need to fix them manually.
the solution is to use code to create termsets and assign GUIDs when you create them. you can use the method below for that.
public TermSet CreateTermSet(string name, Guid newTermSetId, int lcid);
Namespace : Microsoft.SharePoint.Taxonomy
class : Group
Have fun coding...

No comments:

Post a Comment