I am trying to create a newform that has the user name autopopulate on opening the form. I have tried using SPServices.SPGetCurrentUser however I keep getting an error saying unidentified or Null. I am using sharepoint foundation 2013, and I cannot use Visual studio, only Designer with jquery and javascript. Any help would be appreciated.

1 Answer 1


Make sure jQuery is loaded as its working

<script type="text/javascript">
  var userid= _spPageContextInfo.userId;
  var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/getuserbyid(" + userid + ")";
  var requestHeaders = { "accept" : "application/json;odata=verbose" };
    url : requestUri,
    contentType : "application/json;odata=verbose",
    headers : requestHeaders,
    success : onSuccess,
    error : onError

  function onSuccess(data, request){
    var loginName = data.d.Title;

  function onError(error) {

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.