Make Keyword required when uploading a document to a Knowledge Base site


  • This seems like it should be so easy, but I can't find it any where.  I want to require the user to have at least 1 keyword attached to a document before they can upload that document.

    Any ideas?

    • Moved by Mike Walsh FIN Monday, September 19, 2011 2:39 PM presumably needs event handler on doc lib or other programming (From:SharePoint - General Question and Answers and Discussion (pre-SharePoint 2010))
    Monday, September 19, 2011 2:08 PM


All replies

  • Hi,


    You can navigate to knowledge base first, then go to setting>document library settings>Knowledge Base Document(under content Types section)>Keywords and set this column is required.



    Pengyu Zhao

    • Marked as answer by Wayne Fan Thursday, September 29, 2011 6:49 AM
    • Unmarked as answer by lifeIsPunny Thursday, September 29, 2011 12:06 PM
    Tuesday, September 20, 2011 9:29 AM
  • Hi,

     Notice I query with CAML if the list if fields client/matter match with the item I am looking for, if it matches, I get The keywords, don't forget the using's

    using System;
    using System.ServiceModel;
    using System.ServiceModel.Activation;
    using Microsoft.SharePoint;
    using System.Collections;
    using System.Collections.Generic;
    using Microsoft.SharePoint.Client.Services;
    using System.Runtime.Serialization;
    using Microsoft.SharePoint.Taxonomy;
    using System.Globalization;
    using System.Reflection;

    public List<string> GetKeywordsFromClientMatter(string _siteURL, string _library, string _client, string _matter)
                List<string> _aResults = new List<string>();
                    using (SPSite site = new SPSite(_siteURL))
                        using (SPWeb web = site.OpenWeb())
                            System.Collections.Hashtable _tempFileProperties = new System.Collections.Hashtable();

                            SPList _list = web.Lists[_library];

                            SPQuery oQuery = new SPQuery();                      
                            oQuery.Query = @"<Where><And><Eq><FieldRef Name='client' /><Value Type='Text'>" + _client + "</Value></Eq><Eq><FieldRef Name='matter' /><Value Type='Text'>" + _matter + "</Value></Eq></And></Where>";

                            oQuery.RowLimit = 10000;
                            oQuery.ViewAttributes = "Scope=\"Recursive\"";

                            SPListItemCollection collListItems = _list.GetItems(oQuery);

                            //## IF WE HAVE A TEMP FILE TO COPY EVERYTHING...
                            if (collListItems.Count > 0)
                                foreach (SPListItem oListItem in collListItems)
                                    if (oListItem["client"].ToString().ToLower() == _client.ToLower() &&
                                     (oListItem["matter"].ToString().ToLower() == _matter.ToLower()))
                                        Microsoft.SharePoint.Taxonomy.TaxonomyFieldValueCollection _taxonomyTerms = (Microsoft.SharePoint.Taxonomy.TaxonomyFieldValueCollection)oListItem["TaxKeyword"];

                                        foreach (Microsoft.SharePoint.Taxonomy.TaxonomyFieldValue item in _taxonomyTerms)
                                            string _label = item.Label;

                catch (Exception ex)
                    _aResults = null;

                return _aResults;

    Gabriel Renom - Business Systems Analyst - Pannone LLP - Blog:
    Tuesday, September 20, 2011 9:35 AM
  • Thank you for the suggestion - but there is no place at the location you mapped out to mark the keyword as required.  I want to make it required when uploading a document.

    Thursday, September 29, 2011 12:07 PM
  • what you can do is 

    1. Create your custom Site Column (Field) with name as "Keyword"

    here is link how you can create custom site column

    2. You can set type as Single Line Text and mark that as required column

    3. add this created column to the document library

    4. you are done

    hope this helps you 

    Bhushan | |
    • Marked as answer by lifeIsPunny Friday, October 07, 2011 6:51 PM
    Thursday, September 29, 2011 6:03 PM
  • Hi,


    You need set the field to yes for "Allow management of content type", you can find it at settings>document library settings>advanced settings. Then go to setting>document library settings>click Knowledge Base Document(under content Types section)>click Keywords and set this column as required.



    Pengyu Zhao

    Friday, September 30, 2011 1:30 AM
  • Hi,

    Create a custom column , mark it mandatory.

    Add this in all views and this will help you.

    Thanks, Rahul Rashu
    Friday, September 30, 2011 1:56 AM