How to get current user display name at run time using javascript

  • 17 June 2021
  • 3 replies
  • 570 views

Badge +5

Dear Team,

I have calculated value to retrieve current user display name using below

userProfileLookup(Current User, "PreferredName")

given client id vCurrUser and getting that value using below

var varCurrUser = NWF$('#' + vCurrUser).val();

but at runtime varCurrUser is null and yes after loading the page it has a value

My complete code as below

NWF.FormFiller.Events.RegisterAfterReady(function () {
var varCurrUser = NWF$('#' + vCurrUser).val(); 

if(vStatus == "Waiting for Sponsor Approval" && projSponsor == varCurrUser) { // here varCurrUser has null it is not executing if condition.
NWF$('#'+varsponDisc).show();
NWF$('.nf-spComm').show();
NWF$('.nf-sponReject').show();
NWF$('.nf-sponApprove').show();
NWF$('.nf-vsCancel').show();
NWF$('.nf-qualityReview').hide();
}

});

I am also trying to achieve the above using the rule as below

and((Status!="Sponsor Approved" || Status !="New" || Status != "Sponsor Rejected" || Status != "Waiting for Quality Team Review" || Status != "Project Identified as Transformation Initiative" || Status != "Approved By Quality" || Status != "Rejected By Quality") && ProjectSponsorName != userProfileLookup(Current User,"PreferredName"))

 

Any help would be highly appreciated.


3 replies

Userlevel 3
Badge +12

Is the userProfileLookup() funtion did not work? Or any specific reason you are trying it with javascript?


If funtion is not working, make sure the syntax,  it takes "domainloginname" format for first parameter and "internalname" of the property, here is syntax: userProfileLookup("domainlogin","InternalPropertyName")

Badge +5

Yes i have reasons to javascript, team please help me to get current user details at runtime.

Userlevel 3
Badge +12

Try checking the value NWF$('#' + vCurrUser).val() in debug mode.


Nintex wraps lots of css around the control in run time, open the Nintex form, hit F12 key, check for the control's path that shows the display name, and then frame your query to get the display name.

Reply