Iterate inside a CDT

I have the following code:

a!localVariables(
local!a: { 1,2 },
local!b: { 3, 4, 5 },
a!forEach(
items: local!a,
expression: 'type!{urn:com:appian:types:XZY}Employee'(
ID: fv!item,
Value: fv!item,
Field: a!foreach (items:local!b[fv!index], expression: fv!item)
)
)
)

and I want to obtain:

{1,1,3}

{1,1,4}

{1,1,5}

{2,2,3}

{2,2,4}

{2,2,5}

(All outputs must be of type!Employee)

What is the best way to obtain that result, because my code is only generating values for the first one. 

  Discussion posts and replies are publicly visible

Parents Reply Children
  • Ok, understood.

    So, you'll need to nest your a!forEach() loops. The outer one will select a value from local!a. You need to hold that value as a local!variable to be used in the inner loop:

    a!localVariables(
      local!a: { 1,2 },
      local!b: { 3, 4, 5 },
      a!forEach(
        items: local!a,
          expression:  with(
            local!temp: fv!item,
            a!forEach(
            items: local!b,
            expression: 'type!{urn:com:appian:types:XZY}Employee'(
              ID: local!temp,
              value: local!temp,
              field: fv!item
            )
          )
        )
      )
    )