Hello, I have an editable grid that allows for columns to be added dy

Hello,

I have an editable grid that allows for columns to be added dynamically. I have found a strange issue that occurs when the last row in the grid is deleted an error is returned related to the being out of bounds of the array. The only solution I've found is to enclose the entire expression in a Load(), but I'd like to find a way to do this without the Load(). Has anybody ran into this? Can my issue be identified?

Code Below:

load(
a!gridRowLayout(
id: ri!index,
contents: {
a!textField(
label: "First Name" & ri!index,
required: true,
requiredMessage: "A First Name is required for this field.",
value: ri!items[ri!index].FirstName,
saveInto: ri!items[ri!index].FirstName << fn!trim
),
a!textField(
label: "Last Name" & ri!index,
required: true,
requiredMessage: "A Last Name is required for this field.",
value: ri!items[ri!index]....

OriginalPostID-139103

OriginalPostID-139103

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    I was looking at my code when I gave that suggestion! Assuming you itemsToken definition is in a load() try defining "local!itemsToken: ri!externalPerson" The out of bounds array issue is because your rule input has data in it but your token has not yet been initialized so in the gridRow code when you try to remove a value, you can successfully remove it from "ri!items" since it already exists, but we haven't put it in "ri!itemsToken" so we can't remove what isn't there.
Reply
  • 0
    Certified Lead Developer
    I was looking at my code when I gave that suggestion! Assuming you itemsToken definition is in a load() try defining "local!itemsToken: ri!externalPerson" The out of bounds array issue is because your rule input has data in it but your token has not yet been initialized so in the gridRow code when you try to remove a value, you can successfully remove it from "ri!items" since it already exists, but we haven't put it in "ri!itemsToken" so we can't remove what isn't there.
Children
No Data