Note: Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation. To learn more about these changes please visit the announcement which can be found HERE.
add/update a value to the enterprise keyword column programatically

Pertanyaan add/update a value to the enterprise keyword column programatically

  • 01 Mei 2012 8:39
     
     

    Hi, I am not able to find a resource/article which deals with adding a tag grammatically to the enterprise keywords column of a list item in shared docs. An example would be great.

Semua Balasan

  • 01 Mei 2012 9:02
     
     

    Look my blog post (localized!).

    There are some examples.


    Don't happy, be worry...



    • Diedit oleh Aviw_ 01 Mei 2012 9:03
    •  
  • 01 Mei 2012 9:07
     
     
    I went through your post, i think it deals with social tags. I am trying out with enterprise keywords tagging programatically..Or did i read your blog wrong?
  • 01 Mei 2012 11:37
     
     

    The following code, only adds the tags to the TermStore but not to the Enterprise keywords  column of the list.

      SPList list = web.Lists["Shared Documents"];
     SPListItem item = list.GetItemById(2);// Id of the document
      string keywordString = "tag1,tag2"; //comma seperated tags

     TaxonomyField managedField = list.Fields.GetFieldByInternalName("TaxKeyword") as TaxonomyField;

                            if (managedField != null)
                            {
                                TaxonomySession session = new TaxonomySession(item.Web.Site, false);
                                TermStore termStore = session.TermStores[managedField.SspId];
                                TermSet termSet = termStore.GetTermSet(managedField.TermSetId);

                                string[] keywords = keywordString.Split(',').Select(s => s.Trim()).ToArray();

                                var terms = new List<Term>();

                                foreach (string keyword in keywords)
                                {
                                    Term keywordTerm;
                                    if (!termSet.Terms.Any(t => t.Name == TaxonomyItem.NormalizeName(keyword)))
                                    {
                                        keywordTerm = termSet.CreateTerm(keyword, CultureInfo.CurrentCulture.LCID);
                                        termStore.CommitAll();
                                    }
                                    else
                                    {
                                        keywordTerm = termSet.Terms[keyword];
                                    }

                                    terms.Add(keywordTerm);
                                }

                                managedField.SetFieldValue(item, terms);

                            }


                        }



    Code referred from:
    http://sharepoint.stackexchange.com/questions/19389/set-multiple-values-to-enterprise-keywords-taxonomyfield

    It does not however add the tags to the Enterprise keywords  column of the list,Any ideas on how to solve it?


  • 01 Mei 2012 13:46
     
     
    Hello, can somebody help me with this.....i am not able to store  it in the Enterprise keywords column so that it can be tagged and searched....
  • 01 Mei 2012 15:24
     
     
    I am not trying to add it to the TermStore. The program is already successfully adding it to System\Keyword. I am trying to add it to the Enterprise Keywords column of the list and I don't know how to do it ...
    • Diedit oleh sanjuv 01 Mei 2012 15:33 clarification
    •