Nested for each

I have a table of data like this.

  • 1st row contains 3 data,2nd row contains 1 and 3rd row contains 4 like this.
  • I want to apply a nested for each loop for each data of each row and want to apply a rule on each data field.
  • I want to return the whole set of data after applying the rule on each data

How can I achieve this?

Thanks in advance

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    It's not clear to me what this table is (database? gridrowlayout? something else?) so I can't visualize what you are trying to do exactly.

    However, generally speaking, a!forEach can be nested, but you'll need to figure out what the appropriate items value are. From the description, it could be something like this:

    a!forEach(
    items:{1,2,3} /* some value representing the rows */,
    expression:
    if(fv!item=1){ a!forEach(items: row_1_data, expression:...)}
    if(fv!item=2){ a!forEach(items: row_2_data, expression:...)}
    if(fv!item=3){ a!forEach(items: row_3_data, expression:...)}
    )

    forEach would return all resulting values as an array. If you can describe your use case in more detail, I might be able to provide a better suggestion.
  • 0
    Certified Lead Developer
    in reply to Justin Watts

    Hi  adding to    comment, also if you want to hold the values of nested foreach , you can define a local variable on top load() and within foreach you can define an another load() where for each iteration you need to append fv!item to local variable.

    But this approach will cause you performance issue. I recommend, if these data are coming from db, and If they have any relationship, then try to join them and then perform single level of foreach instead of nested.

    Hope this will help you.

Reply Children