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?
If you are new about CAML Query to filter user field, you could use CAML Designer to build CAML:
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.
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:
I can now query by user name or id, so:
<View Scope='RecursiveAll'> <Query> <Where> <Eq> <FieldRef Name='User' /> <Value Type='User'>firstname.lastname@example.org</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.