Using Nintex Form Runtime Lookup Function to populate a textbox

  • 30 July 2014
  • 7 replies
  • 11 views

Badge +3

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.


7 replies

Badge +3

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

Badge +3

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 Else

Badge +3

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

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).

Badge +3

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.

Badge +3

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?

Badge +3

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.

Badge +3

Awesome. Thanks Anthony.

Reply