/
How to Create Quote Line Items from Header Logic

How to Create Quote Line Items from Header Logic

Sometimes it is required to pass values from a header logic to line items that this logic creates. You can use the HIDDEN input type and reference it in the calculation logic.

The following code sample creates a new quote line with parameters fetched from the header logic:

def params = [[name:"MyHiddenParam", type: InputType.HIDDEN, value:"ABC"]] quoteProcessor.addLineItem("ROOT","MB-0003",params)

In the line calculation logic, this value then can be retrieved by:

def val = api.input("MyHiddenParam")

Notes:

  • This way you can also set default values of "real" input parameters as determined by the line calculation logic. Set the value in the header logic and make sure that the names of the parameter match in both logics.

  • If you use this method only to transport values between header & line, set the parameter type to HIDDEN. The value can also be a map to transport more structured data.

  • Any parameter that is non-HIDDEN and not determined by the line logic will be removed.

  • Be aware that this hidden data is also exposed to the user (it is part of the quote response). It is not visible in the UI, but it is neither a secure storage! Also, try to keep the data volume reasonably low.

You can also set default values for items created using the quoteStructure class:

def params = [[name:"MyHiddenParam", type: InputType.HIDDEN, value:"ABC"]] def qs = new QuoteStructure() qs.addPart("MySKU",params) //use add.Folder for a folder

Related content

Pass Values between Quote Header Logic, Configurator and Line Item Logic
Pass Values between Quote Header Logic, Configurator and Line Item Logic
More like this
How to Add a Matrix to Quote Header Output Fields
How to Add a Matrix to Quote Header Output Fields
Read with this
How to Create a Quote from a Logic
How to Create a Quote from a Logic
More like this
How to Set Up a Buy-One-Get-One-Free Promotion
How to Set Up a Buy-One-Get-One-Free Promotion
Read with this
How to Set up Default Value on Header Input and Copy It to Line Items
How to Set up Default Value on Header Input and Copy It to Line Items
More like this
How to Automatically Organize Products into Folders
How to Automatically Organize Products into Folders
Read with this

Found an issue in documentation? Write to us.