Monthly Archives: February 2017

How to get current user id and name in Sharepoint 2013 using Ecma Script

var userid; function GetUserDetails() { clientContext = new SP.ClientContext.get_current(); var oWeb = clientContext.get_web(); currentUser = oWeb.get_currentUser(); clientContext.load(currentUser); clientContext.executeQueryAsync(function () { userid = currentUser.get_id(); usertitle = currentUser.get_title(); }, function (error) { alert(‘Request failed: ‘); }); }

Posted in Uncategorized | Tagged , , , , , , , | Leave a comment

How to run ecma script on Page Load – SP Execute or

SP.SOD.executeFunc(“sp.js”, “SP.ClientContext”, FunctionName); function FunctionName(){ }

Posted in SharePoint | Tagged , , , , , , , , | Leave a comment

How to get logged in user image in SharePoint 2013 (MySite)

$.ajax({ url: _spPageContextInfo.webAbsoluteUrl + “/_api/SP.UserProfiles.PeopleManager”+ “/GetMyProperties?$select=PictureUrl,DisplayName,AccountName”, type: “GET”, contentType: “application/json;odata=verbose”, headers: { “accept”: “application/json;odata=verbose” }, async: false, success: function (data) { var pic = data.d.PictureUrl; var member = data.d.DisplayName; if (pic) { $(“#userName”).text(member); $(“#paduserName”).text(member); $(“.imageicon”).attr(“src”,pic.Url); } else { $(“#userName”).text(member); $(“#paduserName”).text(member); … Continue reading

Posted in Uncategorized | Tagged , , , , , , , , | Leave a comment