Skip to main content
March 25, 2023
Question

Dynamic repeating of rule inside foreach based on one ruleinput

  • March 25, 2023
  • 1 reply
  • 0 views

I have a scenerio.The below mentioned example rule should repat based on the local variable local!a each input.

localvariablesa(

local!a: {"A","B","C"},

local!b : {"X","Y","Z"},

a!forEach(items: local!b,

expression :

rule!getTestData(input1 : ri!employee, input2 : local!a[1])[fvIndex],

rule!getTestData(input1 : ri!employee, input2 : local!a[2])[fvIndex],

.

.

.

.

rule!getTestData(input1 : ri!employee, input2 : local!a[n])[fvIndex],

)

)

    1 reply

    March 25, 2023

    Can you please explain more clearly about the scenario and try    this outstanding feature next time you paste your code to make it more readable and sensible.

    AFAIU, what you want to achieve here can be done using the below sample code:

    a!localVariables(
      local!a: { "A", "B", "C" },
      local!b: { "X", "Y", "Z" },
      a!forEach(
        items: local!b,
        expression: a!localVariables(
          local!index: fv!index,
          a!forEach(
            items: local!a,
            expression: rule!getTestData(input1: ri!employee, input2: fv!item)[local!index]
          )
        )
      )
    )