2

I have used following code on Nintex forms on SharePoint 2013 to get current user details,

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

but it does not work on O365 Nintex forms (Error: _spPageContextInfo is undefined). Is there any equivalent to this approach ? or else what is the best way to get user details? I have tried codes as below,

Sample 01:

SP.SOD.executeOrDelayUntilScriptLoaded(FormLoad(), 'SP.js'); 
function FormLoad()
{
     var userId = _spPageContextInfo.userId;  
     console.log("Current User = " + userId); 
}

Sample 02:

var pollSP;  
NWF.FormFiller.Events.RegisterAfterReady(function () {  
    pollSP = setInterval(checkSPLoad, 500);  
});  

function checkSPLoad() {  
    if (clientContext) {  
        window.clearInterval(pollSP);  
        onSPLoad();  
    }  
}  

function onSPLoad() {  
    var userId = _spPageContextInfo.userId;  
    console.log("Current User = " + userId);  
}  

Note:

  1. SharePoint online site url- "https://abc.sharepoint.com/dev"

  2. Url when the Nintex form is opened- "https://abc-1d0266265ca24d.sharepoint.com/dev/..."

These codes work on on-premise SharePoint 2013 NINTEX form. (it doesn't redirect to app site when the form is opened)

1 Answer 1

0

Try Sample 1 without the brackets after FromLoad on the first line:

SP.SOD.executeOrDelayUntilScriptLoaded(FormLoad, 'SP.js'); 
1
  • Then it doesn't even come to the FormLoad() function Commented Jun 15, 2016 at 4:53

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.