Get the current logged in user properties in Nintex for Office 365

Task:

To load a request form with logged in users full name.

Forms Tool:

Nintex forms for Office 365

Control:

Text control for Name, Email or other properties you wish to display in the form

Make sure your SP is loaded prior to getting the current user details.  If it isn’t included each browser behaves differently some displaying current user name and others not.

var pollSP;
NWF.FormFiller.Events.RegisterAfterReady(function(){
pollSP=setInterval(checkSPLoad,500);
});
function checkSPLoad(){
if(clientContext){
window.clearInterval(pollSP);
onSPLoad();
}
}

function onSPLoad() {
var currentUser = clientContext.get_web().get_currentUser();
clientContext.load(currentUser);
clientContext.executeQueryAsync(function () {
alert(clientContext.get_web().get_currentUser().get_title());
var name = NWF$(“#” + nameVar);
            var curUser = clientContext.get_web().get_currentUser().get_title();
name.attr(“value”, curUser);
        },function(){ alert(“failed to load user”);});
}

That’s it! Preview the form and alert shows fullname(title property) of the current logged in user

2016-08-01_10h15_28.png

Which is assigned to the textbox on load2016-08-01_10h17_07.png

To get email of the logged in user you can user

get_email() property.

             var email = NWF$(“#” + emailVar);

            var curUserEmail = clientContext.get_web().get_currentUser().get_email();

email.attr(“value”, curUser);

Users and Groups in @Nintex forms for Office 365 – Part 2 (Check if current user belongs to a group)

Reference: https://community.nintex.com/thread/11831

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s