Question
Need help comparing current index item to previous index item in a foreach loop
Hello All,
I'm currently creating an editable grid for school records with a field called year graduated. I want the following entries for this field to be compared with previous row to check if the year is greater than the previous row and output an error message. However, I can't seem to find a way to access the previous item. I tried using index function but I'm having a cannot index type error.
a!integerField(
label: "Graduation Year/Expected Year",
labelPosition: "ABOVE",
value: fv!item.yearGraduated,
saveInto: fv!item.yearGraduated,
required: true,
validations: {
if(
fv!index >= 2,
if(
fv!item.yearGraduated > index(fv!item.yearGraduated, fv!index - 1),
"Please enter a valid year",
""
),
""
)
}
)
Any help would be appreciated.
