Hi All,
In this blog, we will see how to fetch user profile properties of all users from SharePoint online.
Many times we need to display specific properties of all users programmatically, so for that, I have Rest API to access User profiles properties. In this case, if properties are mapped to an Active directory then the available data is correct and dynamic.
First we need to add jQuery reference in our file
In this blog, we will see how to fetch user profile properties of all users from SharePoint online.
Many times we need to display specific properties of all users programmatically, so for that, I have Rest API to access User profiles properties. In this case, if properties are mapped to an Active directory then the available data is correct and dynamic.
First we need to add jQuery reference in our file
- <script src="/SiteAssets/JS/jquery.min.js"></script>
SiteUsers is used to get all the users of SharePoint Online site.
- <script>
- $.ajax({
- asynch: false,
- url: "your site url /_api/Web/SiteUsers",
- method: "GET",
- headers: {
- "Accept": "application/json; odata=verbose"
- },
- success: function(data) {
- if (data.d.results.length > 0) {
- for (var i = 0; i < data.d.results.length; i++) {
- var accountName = data.d.results[i].LoginName;
- GetUserProperties(accountName.replace("#", "%23"));
- }
- }
- },
- error: function(x, y, z) {
- alert(JSON.stringify(x) + '\n' + JSON.stringify(y) + '\n' + JSON.stringify(z));
- }
- });
GetUserProperties function is used to get the user profile properties of specific users in SharePoint site.
- function GetUserProperties(user) {
- $.ajax({
- asynch: false,
- url: "your site name/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='" + user + "'",
- method: "GET",
- headers: {
- "Accept": "application/json; odata=verbose"
- },
- success: function(data) {
- console.log("Name = " + data.d.DisplayName);
- //Similarly you can get remaining properties
- console.log("-------------------");
- },
- error: function(data1) {
- alert("ERROR");
- }
- });
- } < /script>
Thank You..

Swastik DasPosted May 24, 2019, 2:37 AM
How to get rid of Name = undefined?
Swastik DasPosted May 24, 2019, 2:36 AM
Firstly Thanks a ton for the post !This returns all the user names but also returns Name = undefined !!
amod tiwariPosted Apr 17, 2018, 12:31 AM
Hi Rashmi, I was looking for such feature to get all employees who are recently hired in organization, I think we can check for created date value to filter out them on basis of last 30 days. Also I didn't used REST API earlier, Not sure how to use it to display this result. Could you please help me to get created users in last 30 days and how to implement it on our site pages in office 365. Thanks
Harsh DPosted Apr 4, 2018, 12:57 AM
Can i get specific propertyName ?
Reshma BhalekarPosted Feb 2, 2018, 9:29 AM
Thank you Naresh....
Naresh SinghalPosted Feb 2, 2018, 5:25 AM
Very Good Explained Madam.......@Rashmi