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

Found an issue in documentation? Write to us.