zoukankan      html  css  js  c++  java
  • Update SharePoint multiple user field

    Sample code:

    item["ParticipantsPicker"]=BuildMultiSPUserValue(new string[]{"user1","user2"},web);

     public static SPFieldUserValueCollection BuildMultiSPUserValue(string[] userValues,SPWeb web)
            {
                SPFieldUserValueCollection userCollection = new SPFieldUserValueCollection();

                foreach (string  item in userValues)
                {
                    SPFieldUserValue userValue = ConvertLoginName(item, web);
                    userCollection.Add(userValue);
                }

                return userCollection;
            }

            private static SPFieldUserValue ConvertLoginName(string userID,SPWeb web)
            {
                SPUser user = web.EnsureUser(userID);
                SPFieldUserValue userValue = new SPFieldUserValue(web, user.ID, user.LoginName);
                return userValue;
            }

  • 相关阅读:
    命名规范
    操作文件和目录
    使用本地shadow socks代理
    发送邮件
    sql参数化
    定义常量
    获取嵌套字典值的方法
    通过字符串调用函数
    用字典优化过长的if 语句
    操作文件和目录
  • 原文地址:https://www.cnblogs.com/csts/p/2482244.html
Copyright © 2011-2022 走看看