0

In a CAMLQuery what token can we use if we want to query against a person or group field with value as our user account?

1

If you are new about CAML Query to filter user field, you could use CAML Designer to build CAML:

CAML Designer

enter image description here

Directly pass the display name as filter value:

  <ViewFields>
      <FieldRef Name='Author' />
   </ViewFields>
   <Where>
      <Eq>
         <FieldRef Name='Author' />
         <Value Type='User'>UserDisplayName</Value>
      </Eq>
   </Where>

Display name can be found in List item UI.

-1

By default, you can only use display name or id in CAML queries for users. But, display name is only the default because that's what the field is configured to display by default. If I go to the field's settings and change what's to be show in the field, like so:

enter image description here

I can now query by user name or id, so:

<View Scope='RecursiveAll'>
  <Query>
    <Where>
      <Eq>
        <FieldRef Name='User' />
        <Value Type='User'>mcsheaj@intellipointsol.com</Value>
      </Eq>
    </Where>
  </Query>
</View>

works in a REST CAML query. Note that changing the Show field will change how the field is displayed in all forms and views too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.