Currently I'm working on SharePoint online app, I'm able to get users from user profile in office 365 site.
Now I'm trying get the Profile details URL :
How can I get that URL for each user using SharePoint APP
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityCurrently I'm working on SharePoint online app, I'm able to get users from user profile in office 365 site.
Now I'm trying get the Profile details URL :
How can I get that URL for each user using SharePoint APP
You need to the UserUrl
property to get the Delve(old mysite) url. Try below code. It iterates through all user profiles and logs the user url in console:
//Get User Profile Property for Site Users
function getUsersDetails(Success,Error) {
var clientContext = new SP.ClientContext.get_current();
var web = clientContext.get_web();
var users = web.get_siteUsers();
clientContext.load(users);
clientContext.executeQueryAsync(
function() {
var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);
var personsProperties = [];
for(var i = 0; i < users.get_count();i++)
{
var user = users.getItemAtIndex(i);
var personName = peopleManager.getUserProfilePropertyFor(user.get_loginName(),'UserUrl');
personsProperties.push(personName);
}
clientContext.executeQueryAsync(
function() {
Success(personsProperties);
},
Error);
},
Error);
}
var scriptbase = _spPageContextInfo.webAbsoluteUrl + '/_layouts/15/';
$.getScript(scriptbase + 'SP.js', function () {
$.getScript(scriptbase + 'SP.UserProfiles.js', function () {
getUsersDetails(function(usersProperties){
for(var i = 0; i < usersProperties.length;i++)
{
console.log(usersProperties[i].get_value());
}
},
function(sender,args){
console.log(args.get_message());
});
});
});
If you want to use REST API, the endpoint would be as below. You need to write your own iteration logic here :
https://sitecollectionurl/_api/SP.UserProfiles.PeopleManager/GetUserProfilePropertyFor(accountName=@v,propertyName='UserUrl')?@v='i:0%23.f|membership|user@tenantname.onmicrosoft.com'
i guess you can use the following url https://tenant-my.sharepoint.com/_layouts/15/me.aspx/?p=JohnDoe%40wortell.nl&v=work