Skip to main content

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")o0]; // Test only - Can be removed

$currRow.find("." + currFieldLabel + " select.nf-client-control")o0])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);

currFieldi0]dparseInt(currFieldValue)].selected = true;

currField.focusout();

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.


Reply