GithubHelp home page GithubHelp logo

Error in documentation? about sharepointplus HOT 3 CLOSED

aymkdn avatar aymkdn commented on June 12, 2024
Error in documentation?

from sharepointplus.

Comments (3)

Aymkdn avatar Aymkdn commented on June 12, 2024

Yes it's an error in the documentation (it will be fixed in the next release).

If you try to get the current user details with Sharepoint 2013 you can also do that:

// a global objet that will contain the info about the current user
var __globalUserDetails={};

// a tiny function to do a REST request
function tiny_rest_json(m,u,c,a,d){with(new(this.XMLHttpRequest||ActiveXObject)("Microsoft.XMLHTTP"))onreadystatechange=function(){readyState^4||c(this)},open(m,u,a),setRequestHeader("Accept","application/json;odata=verbose"),send(d)};

// a function to get the details for the current user
// @param {Boolean} [sync=false] If you want the request to be sync or not
function getGlobalUserDetails(sync) {
  // to get the user ID
  tiny_rest_json("get", "/_api/Web/CurrentUser?$select=Id", function(xhr) {
    __globalUserDetails.userID = JSON.parse(xhr.responseText).d.Id * 1;
  }, sync);

  // find the other infos we want
  tiny_rest_json('get', '/_api/SP.UserProfiles.PeopleManager/GetMyProperties/UserProfileProperties', function(xhr) {
    var results = JSON.parse(xhr.responseText);
    results = results.d.UserProfileProperties.results;
    for (var i=results.length; i--;) {
      switch(results[i]["Key"]) {
        case "PreferredName": __globalUserDetails.preferredName = results[i]["Value"]; break;
        case "LastName":      __globalUserDetails.lastName = results[i]["Value"]; break;
        case "FirstName":     __globalUserDetails.firstName = results[i]["Value"]; break;
        case "WorkEmail":     __globalUserDetails.workEmail = results[i]["Value"]; break;
        case "AccountName":   __globalUserDetails.userName = results[i]["Value"]; break;
        case "Manager":       __globalUserDetails.manager = results[i]["Value"]; break;
      }
    }
  }, sync);
}

getGlobalUserDetails(true);

from sharepointplus.

beruken avatar beruken commented on June 12, 2024

Thank You. Looks like you are migrating away from JQuery?

from sharepointplus.

Aymkdn avatar Aymkdn commented on June 12, 2024

Yes I'll try. I don't really use jQuery anyway (mainly for the AJAX Requests). Also I started to use Sharepoint 2013 so I'll see how I can improve things with that :)

from sharepointplus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.