Skip to main content

Posts

Showing posts from July, 2015

Setting default value for person column to current user in SharePoint 2013 using REST

Add a content editor WebPart to the New form of custom list and add the below code,  replace the  ID of your column highlighted yellow  SetUserFieldValue function parameter to your people picker column name. < script src = " //ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js " >< /script > < script type = " text/javascript " > $( document ).ready( function () { var userid = _spPageContextInfo.userId; function GetCurrentUser () { var requestUri = _spPageContextInfo.webAbsoluteUrl + " /_api/web/getuserbyid( " + userid + " ) " ; var requestHeaders = { " accept " : " application/json;odata=verbose " }; $.ajax({ url : requestUri, contentType : " application/json;odata=verbose " , headers : requestHeaders, success : onSuccess, error : onError }); } function onSuccess ( data , request ){ var loginName = data.d.Title; SetUserFieldValue(