Get the Simple Link URL from Taxonomy of Manage Navigation in SharePoint 2013 using C#

While working for a project we came across the situation of fetching the Taxonomy Terms and creating the dynamics links by referencing the “Simple Link URL” from Manage Navigation properties as we set as below,

Simple links Configuration using Central Admin Console:

The HR node is configured with a link to a page the user will be taken to when clicking on the menu item:

To get the Simple Link URL information using C# code is as below,

foreach (term in termSet.terms)
{
    try
    { 
        string urlHR = term.LocalCustomProperties["_Sys_Nav_SimpleLinkUrl"];
        //Write here code to create <a href link logic 
     }
        catch (KeyNotFoundException ex)
      {
     //Write here code to create Lable logic
   }
}

Below is the list of other available properties with Manage Navigation of SharePoint 2013:

  • _Sys_Nav_Title: the Navigation Node Title
  • _Sys_Nav_FriendlyUrlSegment: the Friendly Url, also represented by the FriendlyUrlSegment property of the NavigationTerm class.
  • _Sys_Nav_TargetUrl: the target URL, also represented by the TargetUrl property of the NavigationTermclass.
  • _Sys_Nav_TargetUrlForChildTerms: the target URL for child terms, also represented by the TargetUrlForChildTerms property of the NavigationTerm class.
  • _Sys_Nav_CatalogTargetUrl: the catalog target URL, also represented by the CatalogTargetUrl property of the NavigationTerm class.
  • _Sys_Nav_CatalogTargetUrlForChildTerms: the catalog target URL for child terms, also represented by the CatalogTargetUrlForChildTerms property of the NavigationTerm class.

For Updating the Terms Navigation Custom Properties:

The Key to understand, by executing the SetLocalCustomProperty method on the_Sys_Nav_Title property, I was able to set the Navigation Node Title:

   term.SetLocalCustomProperty("_Sys_Nav_Title", "myLocation");

If you use that same method with a property name that does not exist, it will create a custom property (which is then visible on the Custom Properties tab); just like the SetCustomProperty method does.

Save your changes to the term store when you’re finished:

   termStore.CommitAll();
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s