0

I have a list called "Employees" where I store an employee's name in the Resource field using the people picker. The people picker allow single values only (no groups). I have other fields (columns) in this Employees List.

Weekly I download this list using the getbytitle/items web API service and I also download the site user information list using _vti_bin/listdata.svc/UserInformationList end point. I download them both for analysis using BI Tools.

The Employees List when downloaded, only shows the ID of the person in the Resource field. This ID is the same ID of the employee in the site's UserInfoList.

In the BI Tools I join the Employees List and the User Information List so I can show info from UserInfo like name, email, dpt, etc.

Due to attrition, when an employee is no longer working for the company, the name of the employee stays in the "Employees" List, but when I download it, it still only shows the ID of the person.

The problem is when I download the UserInfo List, the employee that is no longer working for the company is no longer there, so I can't join them.

However if I go and look at the list using SharePoint web pages, the name of the resource is still displayed.

My question is: Short of storing the employees names in an Excel file, is there a way I can get the deleted or hidden users from the UserInformationList using the web API? I only need the name.

I don't have access to the site collection UserList, I'm only the admin of the site. I tried looking into _catalogs/users/simple.aspx shown here, but only active users show there.

  • ugh, as soon as I asked this, I had an idea and did an expand on the Resource/ID and voilà, it brings the name of the Employee, even if it's not in the User Info List anymore. I'll leave it open in case someone else finds a way to get deleted/hidden users from UserInfo. If not I'll post this comment as an answer. – Jose R Jun 24 at 20:43
0

As you are already using lists/getbytitle()/items endpoint and you are able to get the ID from user column, I will suggest you to use below REST endpoint which will expand the user column and will give you other details like Name, Email, Department, etc.

_api/web/lists/getbytitle('Employees')/items?$select=Title,Resource/Name,Resource/Id&$expand=Resource

Reference:

SharePoint 2013: Get User Details from Person or Group field using REST API

| improve this answer | |
  • Thank you, do you know if there is a way to query UserInformationList so it shows hidden or deleted users? or query AD via web api? Best regards, – Jose R Jun 25 at 12:54
  • From where you have deleted the users? I guess deleted users will not be found in User Information List. Need to check for that. – Ganesh Sanap Jun 25 at 14:09
  • I honestly don't know. The employees have left the company, they do not appear in the site User Information List anymore. But their name still appears in lists where they were stored before leaving the company. So I assume they are still in the AD? – Jose R Jun 25 at 14:16
  • Yes, I also think that it is coming from AD, read more details in this article. Also, try the suggestions given here to get the users from AD. – Ganesh Sanap Jun 25 at 14:26
  • Thanks @Ganesh Sanap, I will look into the 2nd article today a little bit later. – Jose R Jun 25 at 18:41

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.