forEach() Function

Hello Everyone,

Can we achieve the below scenario using the forEach() function?

apply(

  rule!appendTxt(

    txt1: _,

    txt2: _

 ),

merge(ri!txtArr1, ri!txtArr2)

)

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    a!forEach() also has the power to eliminate the need for merge() in most cases, luckily.  There are different ways of doing it, and it partly depends on whether you can be sure your two arrays are of the exact same length, or maybe whether one of them is the "master" array and the other is just supplemental.

    Assuming I want to create output like "Value1 (value2)", something like this could work in these cases:

    a!forEach(
    ri!array1,
    fv!item &
    if(
    isnull(index(ri!array2, fv!index, null())),
    "",
    " (" & ri!array2[fv!index] & ")"
    )
    )
Reply
  • +1
    Certified Lead Developer

    a!forEach() also has the power to eliminate the need for merge() in most cases, luckily.  There are different ways of doing it, and it partly depends on whether you can be sure your two arrays are of the exact same length, or maybe whether one of them is the "master" array and the other is just supplemental.

    Assuming I want to create output like "Value1 (value2)", something like this could work in these cases:

    a!forEach(
    ri!array1,
    fv!item &
    if(
    isnull(index(ri!array2, fv!index, null())),
    "",
    " (" & ri!array2[fv!index] & ")"
    )
    )
Children
No Data