• SharePoint 读取 UserMulti 类型的字段


    话不多说了,写程序的最喜欢代码,代码如下:

    using (SPSite site = new SPSite(""))
                {
                    using (SPWeb web = site.RootWeb)
                    {
                        _list = web.Lists["List"];
                        _query=new SPQuery();
                        foreach (SPListItem item in _list.GetItems(_query))
                        {
                            //SPUser user = item["UserTest2"] as SPUser;  //这一种写法是不正确的 Debug时User为Null
                            //SPFieldUserValueCollection user = item["UserTest2"] as SPFieldUserValueCollection;//这一种写法是不正确的 Debug时User为Null
                            SPFieldUser fieldUser = item.Fields["UserTest"] as SPFieldUser;
                            if (fieldUser.AllowMultipleValues)  //判断是否允许选择多个用户
                            {
                                SPFieldUserValueCollection userValues = item["UserTest"] as SPFieldUserValueCollection;
                                foreach (SPFieldUserValue userValue in userValues)
                                {
                                    if (userValue != null)
                                    {
                                        Console.WriteLine("User LookupId:" + userValue.LookupId);
                                        Console.WriteLine("User LookupValue:" + userValue.LookupValue);
                                        Console.WriteLine("User Email:" + userValue.User.Email);
                                        Console.WriteLine("User LoginName:" + userValue.User.LoginName);
                                        Console.WriteLine("User Name:" + userValue.User.Name);
                                    }
                                    Console.WriteLine();
                                }
                            }
                        }
                    }
                }

  • 相关阅读:
    http请求工具类
    java订单号生成
    SpringUtil获取Spring容器对象
    git push的日志展示问题
    nodejs环境搭建,淘宝镜像cnpm
    csdn里面代码块颜色
    nginx简单使用
    vue项目打包后字体文件路径出错的解决办法
    VUE 爬坑之旅 -- 用 ES6 语法写一个工具类,并全局引用
    VUE 爬坑之旅 -- 用 ES6 语法写一个工具类,并全局引用
  • 原文地址:https://www.cnblogs.com/Fengger/p/2530582.html
Copyright © 2020-2023  润新知