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:
SharePoint online site url- "https://abc.sharepoint.com/dev"
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)