/*Data inputs are: whereTo_txt (text), selectedProduct_cdt (PSH_Product), selectedAgreement_cdt (PSH_Agreement), newOrder_cdt (PSH_ORDER), newItem_cdt (Any Type - Note: In the process model - the type is 'PSH_ITEM' and it's a multiple because there are multiple line items/order) All my data is being saved to the newItem_cdt except for the newItem_cdt.suggestedPrice values */ = load( local!itemToken, /*local!total: if(isnull(ri!newItem_cdt.suggestedAmount), {}, sum(ri!newItem_cdt.suggestedAmount)),*/ a!formLayout( label: "Request to Initiate Purchase (RIP) for "& ri!selectedProduct_cdt.name, instructions: "Enter the line items associated with this agreement renewal.", firstColumnContents: { a!sectionLayout( label: "Product Information", firstColumnContents: { a!textField( label: "Product", labelPosition: "ABOVE", value: ri!selectedProduct_cdt.name, saveInto: ri!selectedProduct_cdt.name, refreshAfter: "UNFOCUS", readOnly: true, validations: {} ) }, secondColumnContents: { a!textField( label: "Line Item Subtotal", labelPosition: "ABOVE", value: if(isnull(ri!newItem_cdt), null, if(fn!length(ri!newItem_cdt)<=0,null,fn!sum(ri!newItem_cdt.suggestedAmount)), /* Note: if you want to update ri!newOrder_cdt.clinSubtotal, send to the psh_itemRows or use a!save(ri!newOrder_cdt.clinSubtotal,sum(ri!newItem_cdt.suggestedPrice)) under any of the sail component in this interface with which you will interact I don't understand what you mean here? Should I add 'ri!newOrder_cdt.clinSubtotal' to the psh_itemRows rule? Please ignore my comments here and the expression written in value part should do the job. */ saveInto: ri!newOrder_cdt.clinSubtotal, refreshAfter: "UNFOCUS", readOnly: true, validations: {} ) } ), a!sectionLayout( label: "Line Items", /* Editable Grid for CLIN Line Items: Takes in: Item Number, Description, Sources, Sole Source, Quantity, Unit Issue, Unit Price, Suggested Price */firstColumnContents: { a!gridLayout( headerCells: { a!gridLayoutHeaderCell(label: "Item Number"), a!gridLayoutHeaderCell(label: "Description"), a!gridLayoutHeaderCell(label: "Sources"), a!gridLayoutHeaderCell(label: "Sole Source"), a!gridLayoutHeaderCell(label: "Quantity"), a!gridLayoutHeaderCell(label: "Unit Issue"), a!gridLayoutHeaderCell(label: "Unit Price"), a!gridLayoutHeaderCell(label: "Suggested Price"), a!gridLayoutHeaderCell(label: "") }, columnConfigs: { a!gridLayoutColumnConfig(width: "NARROW"), a!gridLayoutColumnConfig(width: "DISTRIBUTE"), a!gridLayoutColumnConfig(width: "DISTRIBUTE"), a!gridLayoutColumnConfig(width: "NARROW"), a!gridLayoutColumnConfig(width: "NARROW"), a!gridLayoutColumnConfig(width: "NARROW"), a!gridLayoutColumnConfig(width: "DISTRIBUTE"), a!gridLayoutColumnConfig(width: "DISTRIBUTE"), a!gridLayoutColumnConfig(width: "NARROW") }, rows: a!applyComponents( function: rule!psh_itemRows( newItem_cdt: ri!newItem_cdt, index: _, itemToken: local!itemToken ), array: if( or( isnull( ri!newItem_cdt ), count( ri!newItem_cdt ) < 1 ), {}, 1 + enumerate( count( ri!newItem_cdt ) ) ), arrayVariable: local!itemToken ), validations: if( or( isnull( ri!newItem_cdt ), count( ri!newItem_cdt ) < 1 ), "You must enter a line item", { with( local!total: sum( ri!newItem_cdt.suggestedPrice ), if( local!total < ri!newOrder_cdt.clinSubtotal, "The sum of the line items must be greater than zero.", "" ) ) } ) ), /* Link that adds a new row for the editable grid */a!linkField( label: "Add Link", labelPosition: "COLLAPSED", links: a!dynamicLink( label: "+ Add Line Item", value: 'type!{urn:com:appian:types}PSH_Item'(), saveInto: { a!save( ri!newItem_cdt, append( ri!newItem_cdt, save!value ) ), a!save( local!itemToken, append( local!itemToken, save!value ) ) } ) ) } ) }, secondColumnContents: {}, buttons: a!buttonLayout( primaryButtons: { a!buttonWidgetSubmit( label: "Submit", style: "PRIMARY", saveInto: { } ) }, secondaryButtons: { a!buttonWidgetSubmit( label: "Cancel", style: "NORMAL", value: true, saveInto: ri!whereTo_txt, skipValidation: true ) } ), validations: {} ) )