cancel
Showing results for 
Search instead for 
Did you mean: 
john_luangci
Nintex Newbie

Using Nintex Form Runtime Lookup Function to populate a textbox

Jump to solution

Hello,

 

I've currently got a requirement to populate some editable controls in the form with a value based on the result of a lookup to another list.

 

The runtime lookup function is great for displaying information from another list based on values from other controls in the form. Is there any way we can put this information into a textbox for example? e.g. When a user selects a department lookup, the form will look at a list containing approvers and get the person associated with the selected department and populate a person control.

 

The only approach that I can see working at the moment is through JavaScript.

 

Option 1: Somehow leverage the runtime lookup function and use JavaScript to populate another textbox control

I've had a look at the Calculated Value control and noticed that you can put a client ID JavaScript variable name. However there isn't any way to kick start a function once the Calculated Value recalculates and have that update a textbox on the form.

 

Option 2: Perform the list query and population of textbox control in Javascript

 

Would appreciate any inputs or suggestions in meeting this requirement. Thanks in advance.

Labels: (3)
Reply
8 Replies
Not applicable

Re: Using Nintex Form Runtime Lookup Function to populate a textbox

Jump to solution

Hi John,

No answer for you, but I have a similar need and was wondering if you were able to solve this.

I have a form for contact persons.

Contact persons have a lookup column to an organization.

After selecting the organization I would like to copy the address fields of the organization to the address fields of the contact person.

Peter

0 Kudos
Reply
john_luangci
Nintex Newbie

Re: Using Nintex Form Runtime Lookup Function to populate a textbox

Jump to solution

Hi Peter,

 

In my case decided to use workflow to populate the fields we require after the user has submitted the form. (we wanted to keep customizations to a minimum)

 

If you do not have a need for the user to edit the address field on the form I suggest making use of the calculated value control with the lookup function. The thing with this is that you can connect a calculated value control to a column in your form's list.

 

If you are in my scenario where you want to populate the value but allow a user to override or change it, you will need to consider other options.

 

Thanks

 

John

0 Kudos
Reply
asopkow
Nintex Newbie

Re: Using Nintex Form Runtime Lookup Function to populate a textbox

Jump to solution

Hey there, I'm not sure if things have changed since you've posted this, but you're actually able to pass a value from a formula control over to a custom JavaScript function from within the calculated field.

For instance, if you've got a JavaScript function

setMyControl(value){

    NWF$('#'+myControlID).val(value);

}

you can call that by setting the formula in a Calculated Field control as follows:

setMyControl(lookup("myList", "Id", myDropDownControl, "myFillInColum"))

This will call the lookup runtime function every time myDropDownControl is changed and pass the value returned from the lookup into the JavaScript function setMyControl

For more information, check out my blog post about this:

Nintex – Setting Default Single Line Textbox Text from List Lookup | That Must Have Been Somebody El...

Reply
john_luangci
Nintex Newbie

Re: Using Nintex Form Runtime Lookup Function to populate a textbox

Jump to solution

This is really awesome and exactly what I was looking for.

I did not know you can call a Javascript function inside a calculated field control. (I assume you can also do the same thing inside a form variable).

0 Kudos
Reply
asopkow
Nintex Newbie

Re: Using Nintex Form Runtime Lookup Function to populate a textbox

Jump to solution

I believe so.

The important thing to note is that the reference to the control has to be in the formula. If it's in the JS function, it will work once, but the function will not be called again when the control is changed.

0 Kudos
Reply
Highlighted
john_luangci
Nintex Newbie

Re: Using Nintex Form Runtime Lookup Function to populate a textbox

Jump to solution

Thanks Anthony.

I guess there is no way around the function working once? E.g. If I select a value in the drop down, it will populate the text field, but If I change it again, it will not change the populated value?

0 Kudos
Reply
asopkow
Nintex Newbie

Re: Using Nintex Form Runtime Lookup Function to populate a textbox

Jump to solution

Sorry, I may have confused things for you a little bit.

As long as the reference to the named control is in the formula of the calculated field (or variable) then the function will be called again (and the populated value would change). My original reply demonstrates how to get that functionality.

0 Kudos
Reply
john_luangci
Nintex Newbie

Re: Using Nintex Form Runtime Lookup Function to populate a textbox

Jump to solution

Awesome. Thanks Anthony.

0 Kudos
Reply