Editable grid column is showing values but not saving them

Dear all,

I have an invoice style editable grid with item, cost, qty, total etc

I can add and remove items alright and everything is working as should, however, the total column displays values but values in the total column are not getting saved into the CDT.  I have pasted the SAIL code below so perhaps someone can find where the issue might be.  If you can, please advise.

Thanks

a!gridLayout(

totalCount: count(ri!requisitionItems),
headerCells: {
a!gridLayoutHeaderCell(label: "Item" ),
a!gridLayoutHeaderCell(label: "Cost" ),
a!gridLayoutHeaderCell(label: "Qty" ),
a!gridLayoutHeaderCell(label: "Total", align: "RIGHT" ),
/* "Remove" column */
a!gridLayoutHeaderCell(label: "" )
},
/* sizing */
columnConfigs: {
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
a!gridLayoutColumnConfig(width: "ICON")
},

rows: a!forEach(
items: ri!requisitionItems,
expression: a!gridRowLayout(
id: fv!index,
contents: {
/* Item Column*/
a!textField(
label: "Item " & fv!index,
value: fv!item.description,
saveInto: fv!item.description,
required: true
),
/* Cost Column*/
a!floatingPointField(
label: "Cost" & fv!index,
value: fv!item.cost,
saveInto: fv!item.cost,
required:true
),
/* Quantity Column*/
a!integerField(
label: "assignor " & fv!index,
value: fv!item.qty,
saveInto: fv!item.qty,
required:true
),
/* Total Column*/
a!floatingPointField(
label: "Total " & fv!index,
value: if(
or(isnull(fv!item.qty), isnull(fv!item.cost)),
0,
tointeger(fv!item.qty) * todecimal(fv!item.cost)
),
saveInto: fv!item.total,
readOnly: true,
align: "RIGHT"
),

/* Removal Column*/
a!imageField(
label: "delete " & fv!index,
images: a!documentImage(
document: a!iconIndicator("REMOVE"),
altText: "Remove Line Item",
caption: "Remove " & fv!item.description,
link: a!dynamicLink(
value: fv!index,
saveInto: {
a!save(ri!requisitionItems, remove(ri!requisitionItems, save!value))
}
)
),
size: "ICON"
)
}
)
),
addRowlink: a!dynamicLink(
label: "Add Line Item",

value: {
description: ""

},
saveInto: {
a!save(ri!requisitionItems, append(ri!requisitionItems, save!value))
}
),
validations: {
if(
or(isnull(ri!requisitionItems), count(ri!requisitionItems) < 1),
"Please add at least one line item.",
null
)
},
rowHeader: 1
)

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    The SaveInto parameter doesn't get executed without user interaction (on any type of field).  Basically it's useless on a Read Only field.  It looks like you're hoping to have the "value" calculate the total based on the cost and quantity, and that somehow save into the total field - but what "value" sees is strictly for viewing.  What you need to do, is do this operation (the calculation of the total and saving into the total column) in the saveInto parameter of one or more other fields - probably, both in the cost and quantity columns, with if() conditionality to only attempt the calculation when both are non null.

Reply
  • +1
    Certified Lead Developer

    The SaveInto parameter doesn't get executed without user interaction (on any type of field).  Basically it's useless on a Read Only field.  It looks like you're hoping to have the "value" calculate the total based on the cost and quantity, and that somehow save into the total field - but what "value" sees is strictly for viewing.  What you need to do, is do this operation (the calculation of the total and saving into the total column) in the saveInto parameter of one or more other fields - probably, both in the cost and quantity columns, with if() conditionality to only attempt the calculation when both are non null.

Children