Skip to content

Instantly share code, notes, and snippets.

@vman
Last active February 11, 2016 17:03
Show Gist options
  • Select an option

  • Save vman/4701670 to your computer and use it in GitHub Desktop.

Select an option

Save vman/4701670 to your computer and use it in GitHub Desktop.

Revisions

  1. @spfxadmin spfxadmin revised this gist Mar 5, 2013. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions upMult.js
    Original file line number Diff line number Diff line change
    @@ -21,6 +21,9 @@
    //Domain\Username of the user (If you are on SharePoint Online)
    var targetUser = "i:0#.f|membership|vardhaman@yoursite.onmicrosoft.com";

    //If you are on On-Premise:
    //var targetUser = domain\\username

    //Create new instance of UserProfilePropertiesForUser
    var userProfilePropertiesForUser = new SP.UserProfiles.UserProfilePropertiesForUser(clientContext, targetUser, profilePropertyNames);
    userProfileProperties = peopleManager.getUserProfilePropertiesFor(userProfilePropertiesForUser);
  2. @spfxadmin spfxadmin revised this gist Feb 3, 2013. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions upMult.js
    Original file line number Diff line number Diff line change
    @@ -5,9 +5,9 @@
    SP.SOD.executeOrDelayUntilScriptLoaded(loadUserData, 'SP.UserProfiles.js');
    });

    var userProfileProperties = [];
    function loadUserData(){
    var userProfileProperties = [];
    function loadUserData(){

    //Get Current Context
    var clientContext = new SP.ClientContext.get_current();
    @@ -40,8 +40,8 @@

    }

    function onFail(sender, args) {
    alert("Error: " + args.get_message());
    }
    function onFail(sender, args) {
    alert("Error: " + args.get_message());
    }

    })(jQuery);
  3. @spfxadmin spfxadmin revised this gist Feb 3, 2013. 1 changed file with 30 additions and 33 deletions.
    63 changes: 30 additions & 33 deletions upMult.js
    Original file line number Diff line number Diff line change
    @@ -1,47 +1,44 @@
    (function($){

    $(document).ready(function(){

    // Ensure that the SP.UserProfiles.js file is loaded before the custom code runs.
    SP.SOD.executeOrDelayUntilScriptLoaded(loadUserData, 'SP.UserProfiles.js');
    $(document).ready(function(){
    // Ensure that the SP.UserProfiles.js file is loaded before the custom code runs.
    SP.SOD.executeOrDelayUntilScriptLoaded(loadUserData, 'SP.UserProfiles.js');
    });

    var userProfileProperties = [];

    function loadUserData(){

    //Get Current Context
    var clientContext = new SP.ClientContext.get_current();
    //Get Instance of People Manager Class
    var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);
    //Properties to fetch from the User Profile
    var profilePropertyNames = ["PreferredName","PictureURL"];
    //Domain\Username of the user (If you are on SharePoint Online)
    var targetUser = "i:0#.f|membership|vardhaman@yoursite.onmicrosoft.com";
    //Create new instance of UserProfilePropertiesForUser
    var userProfilePropertiesForUser = new SP.UserProfiles.UserProfilePropertiesForUser(clientContext, targetUser, profilePropertyNames);
    userProfileProperties = peopleManager.getUserProfilePropertiesFor(userProfilePropertiesForUser);
    //Execute the Query.
    clientContext.load(userProfilePropertiesForUser);
    clientContext.executeQueryAsync(onSuccess, onFail);
    //Get Current Context
    var clientContext = new SP.ClientContext.get_current();
    //Get Instance of People Manager Class
    var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);
    //Properties to fetch from the User Profile
    var profilePropertyNames = ["PreferredName","PictureURL"];
    //Domain\Username of the user (If you are on SharePoint Online)
    var targetUser = "i:0#.f|membership|vardhaman@yoursite.onmicrosoft.com";
    //Create new instance of UserProfilePropertiesForUser
    var userProfilePropertiesForUser = new SP.UserProfiles.UserProfilePropertiesForUser(clientContext, targetUser, profilePropertyNames);
    userProfileProperties = peopleManager.getUserProfilePropertiesFor(userProfilePropertiesForUser);
    //Execute the Query.
    clientContext.load(userProfilePropertiesForUser);
    clientContext.executeQueryAsync(onSuccess, onFail);

    }

    function onSuccess() {

    var messageText = "\"Preffered Name\" property is "
    + userProfileProperties[0];
    messageText += "\"PictureURL\" property is "
    + userProfileProperties[1];

    alert(messageText);

    }
    function onSuccess() {

    var messageText = "\"Preffered Name\" property is " + userProfileProperties[0];
    messageText += "\"PictureURL\" property is " + userProfileProperties[1];

    alert(messageText);

    }

    function onFail(sender, args) {
    alert("Error: " + args.get_message());
  4. @spfxadmin spfxadmin revised this gist Feb 3, 2013. 1 changed file with 18 additions and 18 deletions.
    36 changes: 18 additions & 18 deletions upMult.js
    Original file line number Diff line number Diff line change
    @@ -10,25 +10,25 @@

    function loadUserData(){

    //Get Current Context
    var clientContext = new SP.ClientContext.get_current();

    //Get Instance of People Manager Class
    var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);

    //Properties to fetch from the User Profile
    var profilePropertyNames = ["PreferredName","PictureURL"];

    //Domain\Username of the user (If you are on SharePoint Online)
    var targetUser = "i:0#.f|membership|vardhaman@yoursite.onmicrosoft.com";

    //Create new instance of UserProfilePropertiesForUser
    var userProfilePropertiesForUser = new SP.UserProfiles.UserProfilePropertiesForUser(clientContext, targetUser, profilePropertyNames);
    userProfileProperties = peopleManager.getUserProfilePropertiesFor(userProfilePropertiesForUser);
    //Get Current Context
    var clientContext = new SP.ClientContext.get_current();

    //Get Instance of People Manager Class
    var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);

    //Properties to fetch from the User Profile
    var profilePropertyNames = ["PreferredName","PictureURL"];

    //Execute the Query.
    clientContext.load(userProfilePropertiesForUser);
    clientContext.executeQueryAsync(onSuccess, onFail);
    //Domain\Username of the user (If you are on SharePoint Online)
    var targetUser = "i:0#.f|membership|vardhaman@yoursite.onmicrosoft.com";

    //Create new instance of UserProfilePropertiesForUser
    var userProfilePropertiesForUser = new SP.UserProfiles.UserProfilePropertiesForUser(clientContext, targetUser, profilePropertyNames);
    userProfileProperties = peopleManager.getUserProfilePropertiesFor(userProfilePropertiesForUser);

    //Execute the Query.
    clientContext.load(userProfilePropertiesForUser);
    clientContext.executeQueryAsync(onSuccess, onFail);

    }

  5. @spfxadmin spfxadmin revised this gist Feb 3, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions upMult.js
    Original file line number Diff line number Diff line change
    @@ -27,8 +27,8 @@
    userProfileProperties = peopleManager.getUserProfilePropertiesFor(userProfilePropertiesForUser);

    //Execute the Query.
    clientContext.load(userProfilePropertiesForUser);
    clientContext.executeQueryAsync(onSuccess, onFail);
    clientContext.load(userProfilePropertiesForUser);
    clientContext.executeQueryAsync(onSuccess, onFail);

    }

  6. @spfxadmin spfxadmin revised this gist Feb 3, 2013. 1 changed file with 9 additions and 9 deletions.
    18 changes: 9 additions & 9 deletions upMult.js
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,10 @@
    (function($){

    $(document).ready(function(){
    // Ensure that the SP.UserProfiles.js file is loaded before the custom code runs.
    SP.SOD.executeOrDelayUntilScriptLoaded(loadUserData, 'SP.UserProfiles.js');
    });
    $(document).ready(function(){
    // Ensure that the SP.UserProfiles.js file is loaded before the custom code runs.
    SP.SOD.executeOrDelayUntilScriptLoaded(loadUserData, 'SP.UserProfiles.js');
    });

    var userProfileProperties = [];

    @@ -20,17 +20,17 @@
    var profilePropertyNames = ["PreferredName","PictureURL"];

    //Domain\Username of the user (If you are on SharePoint Online)
    var targetUser = "i:0#.f|membership|vardhaman@yoursite.onmicrosoft.com";
    var targetUser = "i:0#.f|membership|vardhaman@yoursite.onmicrosoft.com";

    //Create new instance of UserProfilePropertiesForUser
    var userProfilePropertiesForUser = new SP.UserProfiles.UserProfilePropertiesForUser(clientContext, targetUser, profilePropertyNames);
    //Create new instance of UserProfilePropertiesForUser
    var userProfilePropertiesForUser = new SP.UserProfiles.UserProfilePropertiesForUser(clientContext, targetUser, profilePropertyNames);
    userProfileProperties = peopleManager.getUserProfilePropertiesFor(userProfilePropertiesForUser);

    //Execute the Query.
    clientContext.load(userProfilePropertiesForUser);
    clientContext.executeQueryAsync(onSuccess, onFail);

    }
    }

    function onSuccess() {

  7. @spfxadmin spfxadmin revised this gist Feb 3, 2013. 1 changed file with 13 additions and 13 deletions.
    26 changes: 13 additions & 13 deletions upMult.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    (function($){

    $(document).ready(function(){
    $(document).ready(function(){
    // Ensure that the SP.UserProfiles.js file is loaded before the custom code runs.
    SP.SOD.executeOrDelayUntilScriptLoaded(loadUserData, 'SP.UserProfiles.js');
    });
    @@ -10,23 +10,23 @@

    function loadUserData(){

    //Get Current Context
    var clientContext = new SP.ClientContext.get_current();
    //Get Current Context
    var clientContext = new SP.ClientContext.get_current();

    //Get Instance of People Manager Class
    var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);
    //Get Instance of People Manager Class
    var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);

    //Properties to fetch from the User Profile
    var profilePropertyNames = ["PreferredName","PictureURL"];
    //Properties to fetch from the User Profile
    var profilePropertyNames = ["PreferredName","PictureURL"];

    //Domain\Username of the user (If you are on SharePoint Online)
    //Domain\Username of the user (If you are on SharePoint Online)
    var targetUser = "i:0#.f|membership|vardhaman@yoursite.onmicrosoft.com";

    //Create new instance of UserProfilePropertiesForUser
    var userProfilePropertiesForUser = new SP.UserProfiles.UserProfilePropertiesForUser(clientContext, targetUser, profilePropertyNames);
    userProfileProperties = peopleManager.getUserProfilePropertiesFor(userProfilePropertiesForUser);
    //Create new instance of UserProfilePropertiesForUser
    var userProfilePropertiesForUser = new SP.UserProfiles.UserProfilePropertiesForUser(clientContext, targetUser, profilePropertyNames);
    userProfileProperties = peopleManager.getUserProfilePropertiesFor(userProfilePropertiesForUser);

    //Execute the Query.
    //Execute the Query.
    clientContext.load(userProfilePropertiesForUser);
    clientContext.executeQueryAsync(onSuccess, onFail);

  8. @spfxadmin spfxadmin created this gist Feb 3, 2013.
    50 changes: 50 additions & 0 deletions upMult.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    (function($){

    $(document).ready(function(){

    // Ensure that the SP.UserProfiles.js file is loaded before the custom code runs.
    SP.SOD.executeOrDelayUntilScriptLoaded(loadUserData, 'SP.UserProfiles.js');
    });

    var userProfileProperties = [];

    function loadUserData(){

    //Get Current Context
    var clientContext = new SP.ClientContext.get_current();

    //Get Instance of People Manager Class
    var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);

    //Properties to fetch from the User Profile
    var profilePropertyNames = ["PreferredName","PictureURL"];

    //Domain\Username of the user (If you are on SharePoint Online)
    var targetUser = "i:0#.f|membership|vardhaman@yoursite.onmicrosoft.com";

    //Create new instance of UserProfilePropertiesForUser
    var userProfilePropertiesForUser = new SP.UserProfiles.UserProfilePropertiesForUser(clientContext, targetUser, profilePropertyNames);
    userProfileProperties = peopleManager.getUserProfilePropertiesFor(userProfilePropertiesForUser);

    //Execute the Query.
    clientContext.load(userProfilePropertiesForUser);
    clientContext.executeQueryAsync(onSuccess, onFail);

    }

    function onSuccess() {

    var messageText = "\"Preffered Name\" property is "
    + userProfileProperties[0];
    messageText += "\"PictureURL\" property is "
    + userProfileProperties[1];

    alert(messageText);

    }

    function onFail(sender, args) {
    alert("Error: " + args.get_message());
    }

    })(jQuery);