Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
11 replies
Subscribers
7 subscribers
Views
2896 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
Hello, I have an editable grid that allows for columns to be added dy
issamd
over 9 years ago
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
0
issamd
over 9 years ago
...LastName,
saveInto: ri!items[ri!index].LastName << fn!trim
),
a!dropdownField(
label: "Country" & ri!index,
required: true,
choiceLabels: ri!activeCountries.CountryName,
choiceValues: ri!activeCountries.CountryID,
placeholderLabel: cons!FRMR_DROPDOWN_SELECT_ONE_TEXT,
requiredMessage: "A Country is required for this field.",
value: ri!items[ri!index].CountryId,
saveInto: ri!items[ri!index].CountryId
),
a!textField(
label: "Province" & ri!index,
value: ri!items[ri!index].Province,
saveInto: ri!items[ri!index].Province << fn!trim
),
a!linkField(
label: "delete " & ri!index,
align: "CENTER",
links: a!dynamicLink(
label: "Delete",
value: ri!index,
saveInto: {
a!save(
ri!items,
remove(
ri!items,
save!value
...
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
issamd
over 9 years ago
... )
),
a!save(
ri!itemsToken,
remove(
ri!itemsToken,
save!value
)
)
}
)
)
}
)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Josh
Certified Lead Developer
over 9 years ago
Can you attach the grid code?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
issamd
over 9 years ago
Certainly. This is the Grid code and the Row code.
Grid Code.txt
Row Code.txt
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Josh
Certified Lead Developer
over 9 years ago
how is your local!itemsToken defined? In the past how this tokens variable is defined has caused issues with deleting the last item in an editable grid for me.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
issamd
over 9 years ago
It is simply loaded as a local variable on the form.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
issamd
over 9 years ago
How should I define the variable to avoid this issue?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Josh
Certified Lead Developer
over 9 years ago
see if "local!itemsToken: {}" helps
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
issamd
over 9 years ago
I tried that to no avail.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Josh
Certified Lead Developer
over 9 years ago
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.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
>