Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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:

Paste code macro
languagegroovy
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:

Paste code macro
languagegroovy
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 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:

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