An error occurred while executing a save: java.lang.IllegalArgumentException: Invalid index: Cannot update integer index from type List of Null

Certified Associate Developer

Exception:

"Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error [evaluation ID = c36d2:2c0ec] : An error occurred while executing a save: java.lang.IllegalArgumentException: Invalid index: Cannot update integer index from type List of Null"

While converting the list of terms from a rule input to a local variable, I get this error. When using without local variable, I do not get this error.

 local!terms,

***gridlayout*** 

rows: a!forEach(
items: local!terms,
expression: a!gridRowLayout(
id: fv!index,
contents: {
/* For the First Name Column*/
/*a!integerField(*/
/* Labels are not visible in grid cells but are necessary to meet accessibility requirements */
/*label: "term " & fv!index,*/
/*value: fv!item.termnumber,*/
/*saveInto: fv!item.termnumber,*/
/*required: true*/
/*),*/
a!dropdownField(
label: "termnumber " & fv!index,
placeholder: "-- Select -- ",
choiceLabels: 1 + fn!enumerate(40),
choiceValues: 1 + fn!enumerate(40),
value: fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{6abf73fb-af11-4026-9b11-186d712656da}termnumber'],
saveInto: fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{6abf73fb-af11-4026-9b11-186d712656da}termnumber'],
required: true
),
a!dropdownField(
label: "type " & fv!index,
placeholder: "-- Select -- ",
choiceLabels: { "Fixed", "Variable" },
choiceValues: { "Fixed", "Variable" },
value: fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{a673c7c9-3550-4307-b70c-0c059cd57613}type'],
saveInto: fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{a673c7c9-3550-4307-b70c-0c059cd57613}type'],
required: true
),
a!dropdownField(
label: "Feature " & fv!index,
placeholder: "-- Select -- ",
choiceLabels: { "Open", "Closed", "High Ratio" },
choiceValues: { "Open", "Closed", "High Ratio" },
value: fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{4a777bf4-a618-4e52-becc-9fcbd88c04d2}feature'],
saveInto: fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{4a777bf4-a618-4e52-becc-9fcbd88c04d2}feature'],
required: true
),
a!textField(
label: "Description %" & fv!index,
placeholder: "--- --- ---",
value: fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{112cb6a6-ef26-4d57-a120-05a6194fe7f5}description'],
saveInto: fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{112cb6a6-ef26-4d57-a120-05a6194fe7f5}description'],
required: false,
align: "CENTER"
),
/* For the Last Name Column*/
a!floatingPointField(
label: "rate %" & fv!index,
value: fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{9bc7742c-2b8b-4a0c-aaaf-b019659a72c0}rate'],
saveInto: fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{9bc7742c-2b8b-4a0c-aaaf-b019659a72c0}rate'],
required: true
),
/* For the amount Column*/
a!floatingPointField(
label: "amount " & fv!index,
value: fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{effc20bc-5631-4a27-adbb-f03409a8b1ce}amount'],
saveInto: {
fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{effc20bc-5631-4a27-adbb-f03409a8b1ce}amount'],
/*a!save(local!amount, save!value),*/

},
required: true
),
/* For the fee Column*/
a!floatingPointField(
label: "fee " & fv!index,
value: fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{968e7bc3-eab0-4ba6-aa47-a3776b6586f0}fees'],
saveInto: {
fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{968e7bc3-eab0-4ba6-aa47-a3776b6586f0}fees'],
/*a!save(local!fees, save!value)*/

},
required: true
),
a!richTextDisplayField(
value: a!richTextIcon(
icon: "calculator",
altText: "calculate " & fv!index,
caption: "APR " & fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{9bc7742c-2b8b-4a0c-aaaf-b019659a72c0}rate'] & " yr " & fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{9bc7742c-2b8b-4a0c-aaaf-b019659a72c0}rate'] & "%",
link: a!dynamicLink(
value: rule!APR_QRY_filterAprResults(
term_number: fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{6abf73fb-af11-4026-9b11-186d712656da}termnumber'],
rate: fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{9bc7742c-2b8b-4a0c-aaaf-b019659a72c0}rate'],
principal: fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{effc20bc-5631-4a27-adbb-f03409a8b1ce}amount'],
fee: fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{968e7bc3-eab0-4ba6-aa47-a3776b6586f0}fees'],
start_date: today(),
pmpt_per_year: cons!APR_INT_PAYMENTS_PER_YEAR,
compound_freq: cons!APR_INT_COMPOUNDING_FREQ,

),
saveInto: {
local!aprValueHolder,
a!save(
fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{826b9baf-1e36-4e04-9d82-6c768ed351e8}payment'],
local!aprValueHolder.payment
),
a!save(
fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{cec003c5-933f-4607-9902-d6377093a3ba}apr'],
local!aprValueHolder.apr
),
a!save(
fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{d161e89e-f335-4bc7-9799-f2ee58c330eb}costofcredit'],
local!aprValueHolder.costOfCredit
),
a!save(
fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{b1b5fec0-b3d2-4229-bf95-eaedbf66fa27}totalpayments'],
local!aprValueHolder.totalAmount
)
}
),
linkStyle: "STANDALONE",
color: "ACCENT"
)
),
a!floatingPointField(
label: "payment %" & fv!index,
value: fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{826b9baf-1e36-4e04-9d82-6c768ed351e8}payment'],
saveInto: fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{826b9baf-1e36-4e04-9d82-6c768ed351e8}payment'],
required: true,
readOnly: true
),
a!floatingPointField(
label: "apr %" & fv!index,
value: fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{cec003c5-933f-4607-9902-d6377093a3ba}apr'],
saveInto: fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{cec003c5-933f-4607-9902-d6377093a3ba}apr'],
required: true,
readOnly: true
),
/* For the amount Column*/
a!floatingPointField(
label: "cost of credit %" & fv!index,
value: fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{d161e89e-f335-4bc7-9799-f2ee58c330eb}costofcredit'],
saveInto: fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{d161e89e-f335-4bc7-9799-f2ee58c330eb}costofcredit'],
required: true,
readOnly: true
),
/* For the fee Column*/
a!floatingPointField(
label: "total payments " & fv!index,
value: fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{b1b5fec0-b3d2-4229-bf95-eaedbf66fa27}totalpayments'],
saveInto: fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{b1b5fec0-b3d2-4229-bf95-eaedbf66fa27}totalpayments'],
required: true,
readOnly: true
),
/* For the Removal Column*/
a!richTextDisplayField(
value: a!richTextIcon(
icon: "close",
altText: "delete " & fv!index,
caption: "Remove " & fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{6abf73fb-af11-4026-9b11-186d712656da}termnumber'] & " " & fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{9bc7742c-2b8b-4a0c-aaaf-b019659a72c0}rate'],
link: a!dynamicLink(
value: fv!index,
saveInto: {
a!save(local!terms, remove(local!terms, save!value))
}
),
linkStyle: "STANDALONE",
color: "NEGATIVE"
)
),
/* For the Edit Column*/
if(
ri!Edit,
a!richTextDisplayField(
value: a!richTextIcon(
icon: "history",
altText: "View schedule for " & fv!index,
caption: "Schedule for " & fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{6abf73fb-af11-4026-9b11-186d712656da}termnumber'] & " " & fv!item['recordType!{4c7029cd-5a1f-4c04-9d83-0e7aaf4b8463}APR Term.fields.{9bc7742c-2b8b-4a0c-aaaf-b019659a72c0}rate'],
link: a!dynamicLink(
value: fv!index,
saveInto: {
a!save(local!terms, remove(local!terms, save!value))
}
),
linkStyle: "STANDALONE",
color: "ACCENT"
)
),
a!textField(value: "", readOnly: true)
)
}
)
),
showWhen: local!showWhen,
addRowlink: a!dynamicLink(
label: "Add Term",
/*
* For your use case, set the value to a blank instance of your CDT using
* the type constructor, e.g. type!terms(). Only specify the field
* if you want to give it a default value e.g. startDate: today()+1.
*/
saveInto: {
a!save(local!terms, append(local!terms, save!value))
}
),

  Discussion posts and replies are publicly visible