cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Workflow Hero

How to set list lookup field in a repeating section, copied from anothe'r item's repeating section?

Jump to solution

For a project I have included on a Nintex Form an option to select from other items in the list and have both metadata as well as other form data copied into the current new item. All is working well, except for a list lookup in a repeating section. It does select the proper value (seemingly based on the lookup item's list item ID (currFieldValue in snippet below), but when saving the validation rule kicks and says it needs a value selected.

$currRow.find("." + currFieldLabel + " select.nf-client-control").val(currFieldValue);

Considering the fact that outside a repeating section one also has to set the Selected attribute, I would guess this is also required within the repeating section. Whatever I try, it does not seem I've found the proper command setup.

NB: I'm copying from another item using a (JS) query which only returns a list lookup ID value (and thus not also the display value). Using the following snippet did not work for me to set the selected value of my list lookup in the repeating section:

var tmpDispVal = NWF.RuntimeFunctions.SPLookup("Currencies","ID",currFieldValue,"Currency").done(function(data) {

    $currRow.find("." + currFieldLabel + " option:contains(" + data +")").attr("selected", true);

});

 

Also, SPLookup seems to be async..... So any info on a sync version of calling the inline function lookup() from JavaScript would also be welcome.

UPDATE: The following two code snippets did not result in the list lookup doprdown selections in the repeating section to be accepted::

var currField = $currRow.find("." + currFieldLabel + " select.nf-client-control")[0]; // Test only - Can be removed

$currRow.find("." + currFieldLabel + " select.nf-client-control")[0][parseInt(currFieldValue)].selected = true;

$currRow.find("." + currFieldLabel + " select.nf-client-control").val(currFieldValue).focusout();

var currField = $currRow.find("." + currFieldLabel + " select.nf-client-control"); // Test only - Can be removed

currField.val(currFieldValue);

currField[0][parseInt(currFieldValue)].selected = true;

currField.focusout();

0 Kudos
Reply
1 Reply
Workflow Hero

Re: How to set list lookup field in a repeating section, copied from anothe'r item's repeating section?

Jump to solution

In the end I managed to resolve this myself. As I suspected I indeed needed to lookup the lookup value and as before set both the dropdown's Select control value and the (hidden) associated input control:

NWF.RuntimeFunctions.SPLookup("Currencies","ID",currFieldValue,"Currency").done(function(data) {
     // Set selected option select attribute to true (based on currency value)
     $currRow.find("." + currFieldLabel + " option:contains(" + data +")").attr("selected", true);
     // Get ID hidden input control belonging to select
     var hidInputID = $currRow.find("." + currFieldLabel + " select.nf-client-control+input")[0].id;
     // set select input value to <id>;#<value>
     $currRow.find('#' + hidInputID).val(currFieldValue + ';#' + data);
});

The "+input" takes the first input HTML control following the select control (as there are 2 other text (input) controls in the current row.

0 Kudos
Reply