Skip to main content
September 6, 2021
Solved

double layer of a!forEach

  • September 6, 2021
  • 2 replies
  • 0 views

for exmaple:

value:fv!item.value,

saveinto:{a!save(target:ri!value,value:a!forEach(

items:local!rule,

expression:if(

outside fv!item.value=inside fv!item.value,null,null

),

Then how i express?

))}

    Best answer by gayathris111098

    If you need to nest an a!forEach() inside another a!forEach() and want to refer to the outer fv!item, you can either put it in a local variable before calling the second a!forEach() or put the inner call in a separate rule and pass in fv!item via a rule input. For example:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    
    a!forEach(
      items: {"January", "February", "March"},
      expression: a!localVariables(
        local!month: fv!item,
        a!forEach(
          items: {1, 15},
          expression: local!month & " " & fv!item
        )
      )
    )
    

    The above expression returns a three item list containing {"January 1", "January 15"}, {"February 1", "February 15"}, and {"March 1", "March 15"}

    2 replies

    gayathris111098
    September 6, 2021

    If you need to nest an a!forEach() inside another a!forEach() and want to refer to the outer fv!item, you can either put it in a local variable before calling the second a!forEach() or put the inner call in a separate rule and pass in fv!item via a rule input. For example:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    
    a!forEach(
      items: {"January", "February", "March"},
      expression: a!localVariables(
        local!month: fv!item,
        a!forEach(
          items: {1, 15},
          expression: local!month & " " & fv!item
        )
      )
    )
    

    The above expression returns a three item list containing {"January 1", "January 15"}, {"February 1", "February 15"}, and {"March 1", "March 15"}

    gayathris111098
    September 6, 2021

    value: fv!item.value,
    saveinto: {
    a!save(
    target: ri!value,
    value: a!localVariables(
    local!outerLoopItem:fv!item,
    a!forEach(
    items: local!rule,
    expression: if(
    local!outerLoopItem.value = fv!item.value,
    null,
    null
    ))))},