Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Programmatically enable Enterprise keywords in SharePoint 2010
WhatsApp
Vijai Anand Ramalingam
13y
22.7k
0
0
100
Article
Introduction:
Enterprise keywords are used to tag the documents when uploading the documents in the document library. Enterprise documents can be enabled in both SharePoint lists and libraries. Enterprise keywords - Terms are stored in a non-hierarchical way and available for users to key in which is known as folksonomy (free tagging). In this article we will be seeing how to enable Enterprise keywords for a list using SharePoint object model.
Prerequisites:
Managed metadata service application should be configured.
Web application should be associated to the Managed Metadata Service Application.
Programmatically Enable Enterprise Keywords:
To enable Enterprise keywords through UI refer
http://www.c-sharpcorner.com/UploadFile/anavijai/7633
.
To enable enterprise keywords using object model do the following steps:
Open Visual Studio 2010.
Go to File => New => Project.
Select Console Application template from the installed templates.
Add the following references.
Microsoft.SharePoint
Add the following namespaces.
using Microsoft.SharePoint;
Replace Program.cs with the following code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
namespace EnterpriseKeywords
{
class Program
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("http://serverName:22222/sites/Test/"))
{
using (SPWeb web = site.OpenWeb("BL"))
{
SPList list = web.Lists.TryGetList("dl");
if (list != null)
{
SPField field = list.ParentWeb.AvailableFields["Enterprise Keywords"];
if (!list.Fields.ContainsField("Enterprise Keywords"))
{
list.Fields.Add(field);
list.Update();
Console.WriteLine(field.Title + " added successfully to the list");
}
else
{
Console.WriteLine(field.Title + " column already exists in the list");
}
}
else
{
Console.WriteLine(list.Title + " does not exists in the site");
}
Console.ReadLine();
}
}
}
}
}
Build the solution.
Hit F5.
Go to the =>Permissions and Management => Enterprise Metadata and Keywords Settings.
You could see the "Enterprise Keywords" enabled.
enable Enterprise keywords
enable Enterprise keywords in SharePoint
enable Enterprise keywords in SharePoint 2010
Enterprise keywords
how to enable Enterprise keywords
how to enable Enterprise keywords in SharePoint
how to enable Enterprise keywords in SharePoint 2010
Up Next
Ebook Download
View all
Configure MinRole Search and Cloud Hybrid Features in SharePoint Server 2016 and Office 365
Read by 1.6k people
Download Now!
Learn
View all
Membership not found