SharePoint 2013 get current user using JavaScript

前端 未结 11 2486
挽巷
挽巷 2020-12-13 09:32

How to get current user name using JavaScript in Script Editor web part?

11条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-13 10:01

    I had to do it using XML, put the following in a Content Editor Web Part by adding a Content Editor Web Part, Edit the Web Part, then click the Edit Source button and paste in this:

     
    
    
    

    Check the following link to see if your data is XML or JSON:

    https:///_api/web/currentuser

    In the accepted answer Kate uses this method:

    var userid= _spPageContextInfo.userId;
    var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/getuserbyid(" + userid + ")
    

提交回复
热议问题