【问题标题】:How to programmatically add a hashtag to a List item in Sharepoint 2013?如何以编程方式将主题标签添加到 Sharepoint 2013 中的列表项?
【发布时间】:2013-03-19 11:23:10
【问题描述】:

我想使用 C# 组件将特定主题标签添加到 Sharepoint 2013 应用程序上的列表项。 我想模仿“标签和记事板”功能。

我在这里找到了如何在服务器上添加标签http://msdn.microsoft.com/en-us/library/ff770863.aspx,但由于我使用的是 Sharepoint Online,我需要使用客户端 API。

【问题讨论】:

    标签: sharepoint sharepoint-api sharepoint-2013


    【解决方案1】:

    我昨天确实偶然发现了这个,现在无法访问 devbox,但您应该开始在 Microsoft.SharePoint.Client.Social 中查找

    context.Load(context.Web);
    SocialFeedManager socialFeedManager = new SocialFeedManager(context);
    

    如果你不打败我,我会在 devbox 再次上线时提供更多信息! :)

    【讨论】:

      【解决方案2】:

      我终于找到了路:

      public void AsyncEvent(SPRemoteEventProperties properties) {
      
          ...
      
          List lst = clientContext.Web.Lists.GetByTitle(properties.ItemEventProperties.ListTitle);
          clientContext.Load(lst);
          clientContext.ExecuteQuery();
          ListItem item = lst.GetItemById(properties.ItemEventProperties.ListItemId);
      
          clientContext.Load(item.ParentList, l => l.Fields.Where(field => field.Title == "FieldName"));
          clientContext.ExecuteQuery();
      
          foreach(TaxonomyField field in item.ParentList.Fields) {
               TaxonomyFieldValueCollection newTopics = new TaxonomyFieldValueCollection(clientContext, String.Empty, field);
               newTopics.PopulateFromLabelGuidPairs("Term A Label|term-a-unique-id;Term B Label|term-b-unique-id");
               field.SetFieldValueByValueCollection(item, newTopics);
          }
      
          item.Update();
          clientContext.ExecuteQuery();
      

      如果您找到更好的解决方案,请发布,这个很好用。

      如果您想知道如何格式化“术语标签|术语唯一 ID”,请查看 Sharepoint 管理页面下的分类术语库。术语的唯一 id 示例:d5e733d2-a904-4bee-afbd-632440fdc125。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-01-09
        • 1970-01-01
        • 2010-11-22
        • 2023-03-03
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多