Request a Quote

Get Sharepoint Term’s Custom Local Property values (Server side)

Get Sharepoint Term’s Custom Local Property values (Server side)

We can get values of Custom local properties using server side code. There is no direct way to get custom local from terms. For that we need to do manual coding which is as follow:

 

/// Get Custom Local Property values of particular term.
private void GetCustomLocalPropertyValues(Term term)
{
       int valCnt = 0;
       int keyCnt = 0;
       string property1Val = null;
       string property2Val = null;
       string property3Val = null;
       int property1KeyId = 0;
       int property2KeyId = 0;
       int property3KeyId = 0;
       foreach (var custPropKey in term.LocalCustomProperties.Keys)
       {
       	keyCnt++;
              if (custPropKey == "Property1")
              	property1KeyId = keyCnt;
              if (custPropKey == "Property2")
              	property2KeyId = keyCnt;
              if (custPropKey == "Property3")
              	property3KeyId = keyCnt;
       }
       foreach (var custProp in term.LocalCustomProperties.Values)
       {
       	valCnt++;
              if (valCnt == property1KeyId)
              	property1Val = custProp;
              if (valCnt == property2KeyId)
              	property2Val = custProp;
              if (valCnt == property3KeyId)
              	property3Val = custProp;
       }
 }

 

See my previous blog : How to Create Custom Local Property in Sharepoint Terms

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright © 2015 Trimantra Software Solution LLP- Software Outsourcing Company India. All rights reserved.