September 10, 2013

SharePoint: Output Term Guid instead of Label using TaxonomyFieldControl


In SharePoint Designer, you can output value of a Managed Metadata field of a Publishing Page using

<Taxonomy:TaxonomyFieldControl FieldName="MyCategory" runat="server"/>

How to output the Guid (TermId) of the term/terms instead? How to display term id?


Using the field name appended with _0, you can use SharePointWebControls:FieldValue to output Taxonomy Field value including the TermId.

<SharePointWebControls:FieldValue FieldName="MyCategory_0" runat="server"/>

This outputs the value in Label|TermId format, and separates multiple terms using semi-colon, so it's straightforward to clean that up using, e.g., JavaScript and use the TermIds.

Example: Finland|b7ebb80f-4fd2-4e46-8761-377b5c49f147;Nokia|eea4c90d-efaf-48ea-b094-99218b4ceae1

Technorati Tags:

1 comment:

  1. Thanks for this! If you are using internal names the FieldName is: