/
Accessing Inputs and Outputs in Header and Workflow Logics

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 }

 

Related content

Performance Practices in Analytics
Performance Practices in Analytics
Read with this
How to pass results calculated in the quote header logic to the line items?
How to pass results calculated in the quote header logic to the line items?
More like this
How to Do Calculations on Quote Header Level
How to Do Calculations on Quote Header Level
More like this
Caching Strategies in Configuration
Caching Strategies in Configuration
Read with this
How to Create Quote Line Items from Header Logic
How to Create Quote Line Items from Header Logic
More like this

Found an issue in documentation? Write to us.