Process Model error fv!index variable not found! due to foreach inside foreach and unable to differentiate between fv!item. Please help fix the error.

Below is the code being used as part of a wizard which has foreach inside expression of a foreach to set columns size. When this page is added as a startform to be able to show on a Site, the Process model is throwing below error. It could be because it is not able to identify difference between fv!item in both the foreach loops. How to fix this error or add the page to site?

Errors

This process model could not be published due to the following errors. Please correct them before continuing.

 

Code

a!columnsLayout(
columns: a!forEach(
items: enumerate(
if(
mod(
length(
local!data
),
local!maxItemsPerColumn
) = 0,
length(
local!data
) / local!maxItemsPerColumn,
floor(
length(
local!data
) / local!maxItemsPerColumn
) + 1
)
) + 1,
expression: with(
local!indices: enumerate(
if(
(
fv!item * local!maxItemsPerColumn
) > length(
local!data
),
length(
local!data
) - (
(
fv!item - 1
) * local!maxItemsPerColumn
),
local!maxItemsPerColumn
)
) + (
if(
fv!isFirst,
0,
(
fv!item - 1
) * local!maxItemsPerColumn
) + 1
),
a!columnLayout(
width: "AUTO",
contents: {
a!forEach(
items: local!indices,
expression: a!checkboxField(
labelPosition: "COLLAPSED",
choicelabels: local!data[fv!item].text,
choiceValues: {
true
},
value: if(
local!data[fv!item].boolean,
local!data[fv!item].boolean,
null
),
saveInto: {
a!save(
target: local!data[fv!item].boolean,
value: not(
local!data[fv!item].boolean
)
)
}
)
)
}
)
)
),
showWhen: or(local!currentStep = 1)
),

  Discussion posts and replies are publicly visible

Parents Reply Children
  • load(
    local!currentStep:1,
    local!data:{{text:"123213",boolean:false},{text:"test8",boolean:false},
    {text:"test9",boolean:false},{text:"test",boolean:false},{text:"test1",boolean:false},{text:"test2",boolean:false},{text:"test3",boolean:false},{text:"test4",boolean:false},{text:"test5",boolean:false},{text:"test6",boolean:false},{text:"test7",boolean:false}},
    local!maxItemsPerColumn:3,
    a!columnsLayout(
    columns: a!forEach(
    items: enumerate(
    if(
    mod(
    length(
    local!data
    ),
    local!maxItemsPerColumn
    ) = 0,
    length(
    local!data
    ) / local!maxItemsPerColumn,
    floor(
    length(
    local!data
    ) / local!maxItemsPerColumn
    ) + 1
    )
    ) + 1,
    expression: with(
    local!indices: enumerate(
    if(
    (
    fv!item * local!maxItemsPerColumn
    ) > length(
    local!data
    ),
    length(
    local!data
    ) - (
    (
    fv!item - 1
    ) * local!maxItemsPerColumn
    ),
    local!maxItemsPerColumn
    )
    ) + (
    if(
    fv!isFirst,
    0,
    (
    fv!item - 1
    ) * local!maxItemsPerColumn
    ) + 1
    ),
    a!columnLayout(
    width: "AUTO",
    contents: {
    a!forEach(
    items: local!indices,
    expression: a!checkboxField(
    labelPosition: "COLLAPSED",
    choicelabels: local!data[fv!item].text,
    choiceValues: {
    true
    },
    value: if(
    local!data[fv!item].boolean,
    local!data[fv!item].boolean,
    null
    ),
    saveInto: {
    a!save(
    target: local!data[fv!item].boolean,
    value: not(
    local!data[fv!item].boolean
    )
    )
    }
    )
    )
    }
    )
    )
    )
    /*showWhen: or(*/
    /*local!currentStep = 1*/
    /*)*/
    )
    )

    use this code,..small modifications
  • what are changes? noticed showwhen is commented out but this column layout is part of a wizard and need it. what is the change that fixes it?
  • okay, u can uncommented that code.
    Can u please save this rule, and pass in process model,there is no issue.

    I think, there is a issue in ur parent rule.
  • Issue fixed, there was an index in a expression rule outside this process and UI. Thank You Bhanu.