How to store multiples columns value of another list on nintex form

  • 5 February 2020
  • 1 reply
  • 2 views

Badge +1

Hi,
I am new in Nintex facing problem need yor help.
i was successfully store one column value from another list using lookup function in calculate value action,now How to store more than one columns value with more than one filter columns from another list on nintext form.
is it possible, if yes then how can i do it ?


1 reply

Badge +8

Hi Haider,

a calculated value lookup may only contain one filter.

You can however put multiple lookups with your different filter values (f.e. Modifed and Title) to your form and always output the same column (let´s say id)

What you end up with is multiple arrays, which contain the correct ids for one filter. You can then take a look at those arrays and check which values are contained in all of them.

Those items are the ones which satisfy all your filters.

 

Example

use following js function (caution: this needs to be transpiled to work on older browsers) you get values which are available in all provided arrays

function intersectArrays(...arrays) {
  //get first element of arrays
  const arr0 = arrays.shift();
  //if the remaining arrays length is 0, there is no need to intersect anymore.
  if (arrays.length === 0) {
    //Exit condition
    return arr0;
  }

  //intersect the first and second element
  const arr1 = arrays.shift();
  const intersected = arr0.filter(elt => arr1.indexOf(elt) !== -1);

  //and intersect the intersected ones with the remaining arrays - recursive
  return intersectArrays(intersected, ...arrays);
}
  • Add this function to your form in the js section
  • Add a calculated value which will hold the IDs of elements which satisfy all filters
    in the formula, add
    intersectArrays(myLookupFormula01, myLookupFormula02, myLookupFormula03)
    //Or any other number myLookupFormula
    where myLookupFormulaXX looks as follows:
    lookup("MyList","MyField","MyFilter","ID",true)
    Please note the last parameter, which tells nintex that you want multiple return values

 

This has the nice side effect, that your last calculated value will rerun the javascript function each time a myLookupControl changes.
But please keep in mind that that also costs perfomance, so maybe it is better to intersect the arrays via button click or something else.

Reply