Hello,
I created a Editable Grid in a Form Layout with calculated fields thanks to local variables.
My aim is to save these total fields in rule inputs, particularly into a array of CDT type, using the submit button of the form.
I can't put a submit button in the load to have access to the local variables.
The main CDT is prop, and the multiple values field is items of type CDT propitems. These are the two CDTs :
This is the code of my grid in my form to add a new prop :
load( local!items: { {item: "item1", qty: 1, unitPrice: 4300}, {item: "item2", qty: 2, unitPrice: 20}, {item: "item3", qty: 1, unitPrice: 25} }, local!selected : tointeger({}), local!choix1 :tointeger({}), local!choix2 :tointeger({}), local!markup, local!licence : todecimal({}), a!gridLayout( label: "Produits", instructions: "Selected: " & local!selected, headerCells: { a!gridLayoutHeaderCell(label: "Item"), a!gridLayoutHeaderCell(label: ""), a!gridLayoutHeaderCell(label: ""), a!gridLayoutHeaderCell(label: "Mark up"), a!gridLayoutHeaderCell(label: "Quantité", align: "RIGHT"), a!gridLayoutHeaderCell(label: "Prix Untaire", align: "RIGHT"), a!gridLayoutHeaderCell(label: "Total", align: "RIGHT") }, rows: { a!gridRowLayout( id: 1, contents: { a!textField( value: local!items[1].item, saveInto: local!items[1].item, readOnly: true ), a!textField( readOnly: true ), a!textField( readOnly: true ), a!textField( readOnly: true ), a!integerField( value: local!items[1].qty, saveInto: local!items[1].qty, readOnly: true, align: "RIGHT" ), a!floatingPointField( value: local!items[1].unitPrice, saveInto: local!items[1].unitPrice, readOnly: true, align: "RIGHT" ), a!textField( value: euro(tointeger(local!items[1].qty) * todecimal(local!items[1].unitPrice)), readOnly: true, align: "RIGHT" ) } ), a!gridRowLayout( id: 2, contents: { a!textField( value: local!items[2].item, saveInto: local!items[2].item, readOnly: true ), a!textField( readOnly: true ), a!textField( readOnly: true ), a!textField( readOnly: true ), a!integerField( value: local!items[2].qty, saveInto: local!items[2].qty, align: "RIGHT" ), a!floatingPointField( value: local!items[2].unitPrice, saveInto: local!items[2].unitPrice, align: "RIGHT" ), a!textField( value: euro(tointeger(local!items[2].qty) * todecimal(local!items[2].unitPrice)), readOnly: true, align: "RIGHT" ) } ), a!gridRowLayout( id: 3, contents: { a!textField( value: local!items[3].item, saveInto: local!items[3].item, readOnly: true ), a!radioButtonField( label: "", labelPosition: "ABOVE", choiceLabels: {"Opt 1", "Opt2"}, choiceValues: {1, 2}, value: if(isnull(local!choix1),1,local!choix1), saveInto: {local!choix1, if( and(local!choix1 = 1,local!choix2 = 1), a!save(local!items[3].unitPrice,"27"), if( and(local!choix1 = 1,local!choix2 = 2), a!save(local!items[3].unitPrice,"54"), if( and(local!choix1 = 2,local!choix2 = 1), a!save(local!items[3].unitPrice,"18"), a!save(local!items[3].unitPrice,"36"))))}, choiceLayout: "STACKED", validations: {} ), a!radioButtonField( label: "", labelPosition: "ABOVE", choiceLabels: {"Opt1", "Opt2"}, choiceValues: {1, 2}, value: if(isnull(local!choix2),1,local!choix2), saveInto: {local!choix2, if( and(local!choix1 = 1,local!choix2 = 1), a!save(local!items[3].unitPrice,"27"), if( and(local!choix1 = 1,local!choix2 = 2), a!save(local!items[3].unitPrice,"54"), if( and(local!choix1 = 2,local!choix2 = 1), a!save(local!items[3].unitPrice,"18"), a!save(local!items[3].unitPrice,"36"))))}, choiceLayout: "STACKED", validations: {} ), a!floatingPointField( value: local!markup, saveInto: local!markup, align: "RIGHT" ), a!integerField( value: local!items[3].qty, saveInto: local!items[3].qty, align: "RIGHT" ), a!textField( value: if( and(local!choix1 = 1,local!choix2 = 1), "27", if( and(local!choix1 = 1,local!choix2 = 2), "54", if( and(local!choix1 = 2,local!choix2 = 1), "18", "36"))), saveInto: local!items[3].unitPrice, readOnly: true, align: "RIGHT" ), a!textField( value: if( isnull((todecimal(local!items[3].unitPrice)+todecimal(local!markup))*tointeger(local!items[3].qty)), "--", euro((todecimal(local!items[3].unitPrice)+todecimal(local!markup))*tointeger(local!items[3].qty))), readOnly: true, align: "RIGHT" ) } ), a!gridRowLayout( id: 4, contents: { a!textField( readOnly: true ), a!textField( readOnly: true ), a!textField( readOnly: true ), a!textField( readOnly: true ), a!textField( labelPosition: "ADJACENT", value: "Total 1", readOnly: true ), a!checkboxField( choiceLabels: "", choiceValues: 1, saveInto: {a!save(ri!prop.totalAppian,sum(a!forEach( local!selected, todecimal(local!items[fv!item].qty) * todecimal(local!items[fv!item].unitPrice)+todecimal(local!markup) ))), a!save(ri!prop.items,append(ri!prop.items,'type!{urn:com:appian:types}CGP_propItem'(nom:local!items[3].item))) }, align: "RIGHT" ), a!floatingPointField( value:sum(a!forEach( local!selected, todecimal(local!items[fv!item].qty) * todecimal(local!items[fv!item].unitPrice)+todecimal(local!markup) )), saveInto: ri!prop.totalAppian, readOnly: true, align: "RIGHT" ) } ) }, selectionValue: local!selected, selectionSaveInto: local!selected, selectable: true, rowHeader: 1 ) )
So my question is :
How I can save my local data fiels (Totals) in my rule inputs to push it to database via the process ?
Thanks for your help,
Regards
Discussion posts and replies are publicly visible
I think that what divyas was trying to say is that you can add an a!save onto the editable fields so that you calculate the value of the other fields there and then display ri!prop.whatever in the readOnly fields rather than calculating them then.