zoukankan      html  css  js  c++  java
  • 查询PersonOrGroup字段

    原文地址:http://www.stum.de/2008/02/06/querying-the-person-or-group-field-using-spquery/

    Querying the “Person or Group” field using SPQuery (Update)

    One of the weak points of Sharepoint 2007 is documentation. If you want to query a “Person or Group” field, the documentation on MSDN is a bit sparse.
    Here is how to query a person:

    <where>
      
    <eq>
        
    <fieldref name="PersonFieldName"/>
        
    <value type="User">User Display Name</value>
      
    </eq>
    </where>

    Replace PersonFieldName with the internal Name of the Field.
    The two important things here: Value Type is “User”, and the String to search for is the Display Name. So if you have a user called “John Doe” whose login is “mydomain\jdoe”, you have to search for “John Doe”, not for “mydomain\jdoe”.
    There is an obvious drawback to this: What if you have two users called John Doe?

    Sharepoint People or Group SettingsI was quite disappointed that the Person field does not store the LoginName by default and can therefore not be queried for it.
    There are two workarounds. The first one: Go to the properties of the field in the list, and at the bottom you can change “Show Field” to “Account”.
    This has the advantage that you can use the “domain\username” Syntax now. The drawback: The field looks bad in the list as it does now show the Login, not the Display Name with the neat presence status.

    The second workaround: Use the undocumented LookupId property and search for the numeric ID:

    <where>
      
    <eq>
        
    <fieldref name="PersonFieldName" LookupId="TRUE"/>
        
    <value type="int">UserID</value>
      
    </eq>
    </where>

    The UserID is not the “domain\username”, but the numeric internal ID (SPUser.ID). As I use this in a workflow, I can easily access this through workflowProperties.OriginatorUser.ID, which is good enough for me.

    Update: The second code example was incorrect, I fixed it now.

  • 相关阅读:
    Vue之自定义组件的v-model
    compression-webpack-plugin 开启gzip vue
    vue-i18n ,vue项目中如何实现国际化
    vue 组件的 scrollBehavior 2
    vue-router中scrollBehavior的巧妙用法
    页面刷新(vue)
    服务器配置nginx.conf文件
    mobaxterm配置nginx
    flutter环境搭建
    让GIt忽略SSL证书错误的方法
  • 原文地址:https://www.cnblogs.com/chenfulai/p/1409089.html
Copyright © 2011-2022 走看看