Tuesday, June 7, 2011

How to get a Term Metadata Taxonomy

Como encontrar o termo no arquivo de Metadata:

TaxonomySession session = new TaxonomySession(properties.Web.Site);
TermStore termStore = session.TermStores["Serviço de Metadados Geridos"];
Group group = GetByName(termStore.Groups, "Colecção de Sites - server");
TermSet termSet = group.TermSets["Categoria"];//Metadata value
TermCollection tc = termSet.GetAllTerms();
Term t = tc["Programas"];

Ops using Microsoft.SharePoint.Taxonomy;

;)) Assim consegui-mos o Term/termo.

SetFieldDefault Metadata - term default na folder/pasta ou field/campo

Para definir um term default na folder/pasta ou field/campo com metadata, utilizamos:

string term="";
MetadataDefaults metaDefault= new MetadataDefaults(properties.List);
SPFolder folder = web.GetFolder(properties.Web.GetFolder("http://server/site/folder"));
term = "2070;#Programas|bc943091-79ac-4f5f-a79b-205e8e717823";
metaDefault.SetFieldDefault(folder, "Categoria", term);


Term/Termo é composto por:
lcid
;#Term Name|Guid of term

LCID = Language code ID - How to get LCID
Guid of term = Term.id - How to get Guid of Term and term

Hope it helps ;))