Hi All,
Please find the below Code Snippet to Read the Manage Metadata Terms. As an Example iam binding the same to dropdownlist.
//Get the termset
MMS_Term = (from b in MMS.Terms
Please find the below Code Snippet to Read the Manage Metadata Terms. As an Example iam binding the same to dropdownlist.
private void BindMMS() { ddlMMS.DataSource=MMS_Terms("http://siteUrl:11"); ddlMMS.DataBind(); }
public List<string> MMS_Terms(string siteUrl)
{
List<string> MMS_Term = new List<string>();
try
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite oSite = new SPSite(siteUrl))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
oWeb.AllowUnsafeUpdates = true;
TaxonomySession _TaxonomySession = new TaxonomySession(oSite);
//Get instance of the Term Store
TermStore _TermStore =
_TaxonomySession.TermStores["ManagedMetaDataServiceAppName"];
_TaxonomySession.TermStores["ManagedMetaDataServiceAppName"];
//Get instance of Group
Group group = _TermStore.Groups.FirstOrDefault(e => e.Name =="Name of the Group");
//Get the termset
TermSet termSet_ProjectTerms = group.TermSets.FirstOrDefault(e => e.Name == "Name of the Termset");
Term MMS = termSet_ProjectTerms.Terms.FirstOrDefault(t => t.Name =="Name of Term");
MMS_Term = (from b in MMS.Terms
select b.Name).ToList();
}
}
});
}
catch (Exception ex)
{
// exception
}
return MMS_Term;
}
Related Post
Managed Metadata Service
SharePoint
- Build Automation (CICD) of WebJob in SharePoint Online
- List view render using JSLink with Fabric UI
- Delete Quick Links using Powershell
- SharePoint Interview Questions and Answers..
- Issues:SharePoint Foundation 2013 Prerequisites installation(off line) on Windows Server2012 R2
- SharePoint Column Field Types
- Alternate to InfoPath Forms in SharePoint
- Get the Items inside the Folder in document Library in SharePoint 2013 using REST API
- SharePoint 2016 [Beta] Release Date
- SharePoint Modal Dailoge to Open Page
- What is Look up Column and how to use in SharePoint 2010,2013
- People Picker Check User Entry and Resolve
- How to Get User Data from AD (Active Directory) in SharePoint Using C#
- History of SHAREpoINt
- How to Create Application Page in SharePoint using Visual Studio 2010,2013
- Retrieve Site Features in SharePoint
- Weather Webpart by using Yahoo Service in Share Point
- Activate Telnet Client in Windows Server
- Navigate to another Page After Clicking on JavaScript Alert
- How to read List Item Version Collection Programmatically
- How to get Worker Process from Command Prompt
- How to Use DataTable.js in SharePoint webpart
- Adding New Link to PromotedActions Delegate Control in SharePoint 2013
- How to Deploy Master Page in Share Point
- Get Role Definition in SharePoint
0 comments:
Post a Comment