I'm trying to get a single field from a list. The list has columns like this:

Office365Account - Type: Person

Email Address - Type: Email

Manager - Type: Person

Basically what I want to do is find the manager associated with the current user of the system.

In SQL I'd do it something like this:

SELECT Manager FROM organizationContactsList WHERE Office365Account = currentuser

I'm pretty sure a CAML query is what I need to (or at least should) use, but I've just begun with SharePoint/SharePoint App programming and the structure of CAML queries baffle me. Any pointers on what this would look like in CAML?

  • Are you using onpremise sharepoint or sharepoint online?
    – Aanchal
    Jun 6 '14 at 14:52
  • SharePoint Online; this is for a App written using the JavaScript Object Model.
    – Ectropy
    Jun 6 '14 at 14:53

You can use the following CAML query :

    <FieldRef Name="Office365Account" />
    <Value Type="Integer">
      <UserID />
  • Ah this makes more sense. And to get the UserID for the current user I'd do: currentContext.get_web().get_currentUser().get_id() I think this will solve my issue.
    – Ectropy
    Jun 6 '14 at 15:02
  • For current user you don't need to pass an ID. You can try as it is. If there is problem you can try with ID also.
    – Aanchal
    Jun 6 '14 at 15:03
  • Oh I see. <UserID /> assumes that you're talking about the integer userid for the current user, if I'm not mistaken.
    – Ectropy
    Jun 6 '14 at 15:04
  • Yes, i am assuming Office365Account is a User field.
    – Aanchal
    Jun 6 '14 at 15:05
  • Very good. That simplifies things! (It is a User field in my case.)
    – Ectropy
    Jun 6 '14 at 15:07

You can certainly use CAML for this, but a simple REST call would spit out the manager if you supply the user's claim.


There's a good blog post about pulling User Profile Properties from REST here: http://www.vrdmn.com/2013/07/sharepoint-2013-get-userprofile.html

  • Ah very good. I'll keep this in mind too, and determine which best fits my needs.
    – Ectropy
    Jun 6 '14 at 18:09
  • Oh I see, they have to have a manager associated with their actual account's properties for a query like this to work. In my case our organization doesn't have that manager field filled out, and instead we're using a separate list that groups people and their managers.
    – Ectropy
    Jun 6 '14 at 20:21
  • If you can't use people service then you can just use a REST query to your lookup list; still arguably more efficient than CAML (and a more future proof solution given the deprecation of the SOAP services).
    – webdes03
    Jun 8 '14 at 13:43

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.