AnsweredAssumed Answered

How can I set a value in a text field using JavaScript?

Question asked by akalmar on Apr 3, 2017
Latest reply on Apr 4, 2017 by akalmar

I have searched the Nintex Community and tried many of the things that were recommended.  Unfortunately, I still haven't had any luck.  I'm trying to auto-populate two text fields: First Name (JavaScript ID "varFirstName") and Last Name (JavaScript ID "varLastName").  I have two calculated fields (which I will later hide when the form goes into production) that get the first and last names of the current user using User Profile Services (lookup formulas are: userProfileLookup(Current User,"FirstName") and  userProfileLookup(Current User,"LastName")).  The calculated fields show the names with no problems.  However, I can't add these values to the two text fields.  This is the JavaScript custom code that I am using.  


NWF.FormFiller.Events.RegisterAfterReady(function () {
var firstName = NWF$('#' + varUserFN).val();  //this refers to the calculated field for first name
var lastName = NWF$('#' + varUserLN).val();  //this refers to the calculated field for last name

NWF$('#' + varFirstName).val(firstName).trigger('blur');
NWF$('#' + varLastName).val(lastName).trigger('blur');



Note that I originally added this code inside of  "NWF$(document).ready(function(){})" as it is more proper to stick with all jQuery or all straight JavaScript, right?  But, neither worked.  I've also tried the suggested from this previously posted question:  Can't populate text control with calculated value .  I hadn't had success with that, either.  What could I be doing wrong?  Any help would be much appreciated!  Thanks in advance!