AnsweredAssumed Answered

Issue on Nintex forms while working with JQuery to get Current User Department.

Question asked by lalitkasa88 on Mar 1, 2017
Latest reply on Mar 15, 2017 by sean.fiene@nintex.com

we trying to get Current user Department from user profile properties , we have used below JS on Nintex forms and we are getting below error-

''  Uncaught ReferenceError: _spPageContextInfo is not defined ''

so we have tried same code which we have used in Nintex forms in Aspx page of SharePoint and we are able to get user properties of current user.

 

So we require your help in this case if you can check the JS code which we have used for Nintex , and guide us in achieving the output in Nintex forms.

below is the JS Code which we have tried :-

 

<script src="/Style%20Library/Js/jquery.SPServices-2013.02a.js" type="text/javascript"></script>

<script src="/Style%20Library/Js/jquery-1.11.1.js" type="text/javascript"></script>

 

<script type="text/javascript">

  var userid= _spPageContextInfo.userId;

  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.LoginName;

    alert(loginName);

  }

 

  function onError(error) {

    alert("error");

  }

</script>

Outcomes