Accessing Inputs and Outputs in Header and Workflow Logics
On a quote line item, the inputs and calculation results are persisted as a List. When you retrieve the value from the list (e.g. in the header logic code), you should consider avoiding find {}
or findAll {}
– for increased performance – and use a map with key-value pairs instead.
Map getItemInputs(def item) {
return item.inputs?.collectEntries { [(it.name): it.value] }
}
Map getItemOutputs(def item) {
return item.outputs?.collectEntries { [(it.resultName): it.result] }
}
Now use these methods for accessing the inputs/outputs:
Recommended:
def items = quoteProcessor.quoteView.lineItems.findAll { !it.folder }
def totalInvoicePrice = items
.sum { item ->
Map itemOut = getItemOutputs(item)
return itemOut.InvoicePrice * itemOut.Quantity
}
To be avoided:
def items = quoteProcessor.quoteView.lineItems.findAll { !it.folder }
def totalInvoicePrice = items
.sum { item ->
BigDecimal invoicePrice = item.outputs.find {
it.resultName == "InvoicePrice"
}?.result
BigDecimal quantity = item.outputs.find {
it.resultName == "Quantity"
}?.result
return invoicePrice * quantity
}
Â
Found an issue in documentation? Write to us.
Â