250 likes | 449 Views
Code Tax: Programming With The Taxonomy API In SharePoint 2010. Patrick Tucker. About Me. Patrick Tucker Strategic Data Systems, MS Gold Partner Principal Consultant, SharePoint MCT, MCTS, MCPD, MCITP, MCSD, MCAD, MCDBA Patrick.Tucker@sds-consulting.com | tuckersnet@live.com
E N D
Code Tax: Programming With The Taxonomy API In SharePoint 2010 Patrick Tucker
About Me • Patrick Tucker • Strategic Data Systems, MS Gold Partner • Principal Consultant, SharePoint • MCT, MCTS, MCPD, MCITP, MCSD, MCAD, MCDBA • Patrick.Tucker@sds-consulting.com | tuckersnet@live.com • Blog: www.tuckersnet.com • Twitter: @TuckersNet
The Managed Metadata Experience How do we interact with managed metadata in sharepoint?
Managed Metadata in SharePoint • A way to do classification of content based on attributes • Applies to documents, list items & pages at the column level • Assists SharePoint in being a document management & collaboration platform • Taxonomy and Folksonomy
Where Is Managed Metadata Surfaced? • The Taxonomy picker Control • Managed Metadata Columns • The Document Information Panel • Search
Managed Metadata and Taxonomy • Managed Metadata Service Application • Taxonomy Term Store • Term Sets • Managed Metadata Column Type
Taxonomy Term Store • Available through Managed Metadata Service • Comprised of system or admin created term sets • Term sets may be global or local, open or closed • Hierarchical • Groups contain Term Sets • Term sets contain terms • Terms may have a default label and other labels (Synonyms)
Behind the Scenes • Taxonomies are stored in a single database • Each root site in a site collection contains a “TaxonomyHiddenList” • The “Taxonomy Update Scheduler” timer job syncs hourly to update this list • Taxonomy field values are implemented as lookup columns • The “Managed Metadata” Field is actually comprised of multiple columns • TaxonomyField • TaxKeywordTaxHTField • “TaxCatchAll” • “TaxCatchAllLabel”
Managed Metadata Limitations • Practical Limitations: • Not supported in InfoPath forms • Not supported in SharePoint Workspace • Not supported in Datasheet views • Limited Support in SPD Workflows • Per TechNet, the recommended storage guidelines are: • Max 7 levels of nesting in a term store • Max 1000 term sets in a term store • Max 30,000 terms in a term set • Max 1 million total items in a term store
The Taxonomy API Working with the managed metadata service programmatically
Options • Server side object model (Microsoft.SharePoint.Taxonomy) • Sorry, not available to sandboxed solutions • The Taxonomy Client Service • Declarative XML • PowerShell
Object Model • Need to Reference Microsoft.SharePoint.Taxonomy DLL • Entry point is a new Taxonomy Session, connects to MMS instance • Classes in Taxonomy Namespace mirror Hierarchy Seen in Term Store Management Tool • TaxonomySession class • TermStore class (takes name of MMS Proxy) • Group class • TermSet class • Term class (may contain nested terms)
Terms, Keywords and Synonyms • Terms are either managed terms or enterprise keywords • Each Term may be marked as available for tagging • Each term has a default label • Synonyms are added under the “Other Labels” section • Synonyms are exposed in code through a labels collection on each term. The default label is the first term in the collection.
Creating New Term Store Items In Code • Get a reference to session . . . Term Store • The termStore class contains a CreateGroup method • The Group class contains a CreateTermSet method • The TermSet class contains a create term method Tips to Remember . . . • Adding items to the term store is transactional. We must remember to call “CommitAll()”
DEMO • Traverse the hierarchy of groups, Term Sets and Terms • Display the hierarchy in a tree view control via a custom web part • Create a new group, term set and terms programmatically • Retrieve and display the newly created terms
The Taxonomy Client Service • The taxonomyclientservice.svc is available, but limited • Operations to retrieve term store items and add terms are available
Taxonomy Client Service • Navigate to http://sitecollectionUrl/_vti_bin/taxonomyclientservice.asmx • Do you know the Guids of your term store and term Set? • XML parsing is in your future
The Taxonomy Field Type • Custom list definitions will need to create the field – Declaratively or programmatically (or both) • This field is exposed in the UI via the taxonomy picker control • Page layouts may also make use of this field type to tag pages as well as items and documents
Implementing a Taxonomy Field in a Custom List • Declarative approach • Will need sspID and term set Guids in XML • Programmatic approach • also works with partial declarative code
Setting Taxonomy Field Values • Allows the user to select term(s) to tag content • The control shows up on new and edit forms • The control may be used on custom page layouts
DEMO • Use the taxonomy web service to display term store items • Create a custom list definition that contains a managed metadata column • Set a taxonomy field value for a list item in code
The Undiscovered Country What’s new with managed metadata in SharePoint 2013?
So What’s Changed in 2013? • Managed Metadata Navigation • Terms intended use may be for navigation • Target pages are attached to terms and drive the navigation of the site • CSOM – Client Side Object Model Support • Available to .NET, Silverlight and JavaScript • Projects may reference the Microsoft.SharePoint.Client.Taxonomy assembly • Datasheet view support for the managed metadata column type • Custom properties may be added to a term to store additional Data • More than just additional labels, this is a dictionary of metadata for your metadata • Exposed in the Taxonomy Term Store management UI and in code
Q and A • Patrick.Tucker@sds-consulting.com | tuckersnet@live.com • Blog: www.tuckersnet.com • Twitter: @TuckersNet