1

I need a list of users where the current user is manager of. SharePoint provides the JavaScript function PersonProperties.get_directReports(), the result is a list of login names but I need user IDs to filter a person field in another list.

What would be the most efficient way to get the IDs of direct report users?

  • 1
    Note that user ids are unique PER SiteCollection – Danny '365CSI' Engelman May 29 '17 at 17:38
  • @elsni, could how you are getting values for this method. I am getting always empty array. – Mihir Jun 13 '18 at 16:19
1

There is no efficient way. As mentioned by @Danny'365CSI'Engelman, ids are unique per site collection, while you are using user profile services (which is not correlated with a specific site collection) to get direct reports. So technically you'll not get the ids. However, you can query the whole "User Information List" in JS (using REST or CSOM or ...) and keep it as an array. Then once you get all the users from direct reports, compare and find ids, in case the user does not exist in UIL, call SP.Web.ensureUser which will add the user to UIL and return you the SP.User object with ID.

0

We are using following REST call to get the user id by login name.

siteurl/_vti_bin/listdata.svc/UserInformationList?$filter=Account eq 'account name'

The UserInformationList is a hidden list which stores all site users.

  • Note that the UIL is only filled on first login, so you might not get all users – Danny '365CSI' Engelman May 29 '17 at 17:33
  • Yes. I am assuming the user already visited the site in this case. – Venkat Konjeti May 29 '17 at 17:37

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.