0

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 :

https://Akshay.sharepoint.com/_layouts/15/me.aspx/?u=f0b9ed1d-83fa-4c82-976d-027f02711a83&v=profiledetails

enter image description here

How can I get that URL for each user using SharePoint APP

0

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'
0

i guess you can use the following url https://tenant-my.sharepoint.com/_layouts/15/me.aspx/?p=JohnDoe%40wortell.nl&v=work

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.