Array Expression

Certified Associate Developer

Hi guys/gals,
Some help please with an expression rule I'm trying to create that's driving me nuts.
Here's the simple example:

a!localVariables(
local!array:
{
  { id: 1, deleted: true, activeStep: false },
  { id: 2, deleted: false, activeStep: false },
  { id: 3, deleted: false, activeStep: false },
},

local!array
)

I'm passing a list of Dictionary to the expression (local!array in the example above). I want to return an updated local!array where the activeStep is set to true for the first item where deleted is false.
In my example above, the second row will have its activeStep set to true as the first row's deleted field is true. The third row will remain as is because the second row's activeStep field will be already set to true.

So the returned value should be:
{
  { id: 1, deleted: true, activeStep: false },
  { id: 2, deleted: false, activeStep: true },
  { id: 3, deleted: false, activeStep: false },
}

Seems simple but if I use a!forEach, both the 2nd and 3rd row's activeStep is set to true. I only want the first occurrence.

Cheers...

  Discussion posts and replies are publicly visible

Parents Reply Children
No Data