0

I have a SharePoint list which contains a people or group field where I want to fetch the Id which is stored internally and name is displayed.

Can anyone tell me how to fetch all the values from person or group field using a CAML query?

It would be a great help.

Thanks in advance!!

  • do you have people -group internal name ? – Siddharth Vaghasia Jun 5 at 10:34
  • Does your person or group field allows multiple selections? What do you want to fetch exactly? All the users/groups selected in person or group field or something else?? – Ganesh Sanap Jun 5 at 10:38
0

To fetch the Values in person or group field you can use CAML as given below:

<View><ViewFields><FieldRef Name="PersonFieldName"/></ViewFields></View>

To Query/Filter for particular user on person or group field you can use anyone of below solutions:

<Where>
  <Eq>
    <FieldRef Name="PersonFieldName"/>
    <Value Type="User">User Display Name</Value>
  </Eq>
</Where>

Or

<Where>
   <Eq>
      <FieldRef Name="PersonFieldName" />
      <Value Type="Integer">UserID</Value>
   </Eq>
</Where>

Or

<Where>
   <Eq>
     <FieldRef Name="PersonFieldName" LookupId="TRUE"/>
     <Value Type="int">UserID</Value>
   </eq>
 </Where>

You can also use <UserID/> to get the Id which contains:

Contains the unique ID number of the currently authenticated user of a site, as defined in the UserInfo table of the content database.

Example:

<Where>
   <Eq>
      <FieldRef Name="PersonFieldName" />
      <Value Type="Integer">
         <UserID />
      </Value>
   </Eq>
</Where>

References:

  1. ViewFields element (List).
  2. Query schema.
  3. UserID element (Query).
  • Have you tried using this solution? – Ganesh Sanap Jun 6 at 2:54
  • Actually what I want is, I am fetching all the data from shrepoint ,now that data has one column called user which is of type people group and it displays name , so when i fetch that data using a SOAP call I get just the name not the other details like email, id etc. so is there any way that those details get fetched instead of name – Aastha_gupta Jun 11 at 7:58
  • Is there any particular reason you are using CAML? you can get those details very easily using REST – Ganesh Sanap Jun 11 at 8:07
  • I am bound to use SOAP, not caml – Aastha_gupta Jun 11 at 8:07
  • so using that soap call, I want to get that result – Aastha_gupta Jun 11 at 8:08

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.