Input Builders

Input Builders are a way to build parameters for Configurators and Headers logics to be used in functions api.createConfiguratorEntry().addParameter() or quoteProcessor.addOrUpdateInput(). Previous methods were dependent on being aware of all the InputTypes, logic context (configurator, quote logic, etc.) and manually figuring out what methods are used to set their respective properties. Input Builders handle the selection of the InputType for you and simplify and standardize the implementation of inputs. These methods also fully leverage the JavaDoc so that Pricefx Studio will automatically let you know what properties can be set and how. This structure allows for better readability and re-usability.

For example, here is the previous method for creating a parameter in a Configurator:

def ce = api.createConfiguratorEntry() def p = ce.createParameter(InputType.OPTIONS, "Country") p.setLabel("Select country") p.setValueOptions(["CZ", "DE", "UK"]) if (p.value == null) { p.value = "DE" }

It is important to note that the developer would have to know on their own to use InputType.OPTIONS, p.setLabel(), and p.setValueOptions(). Now this is the updated way of doing so with an Input Builder:

def country = api.inputBuilderFactory() .createOptionEntry("Country") .setLabel("Select Country") .setOptions(["CZ", "DE", "UK"]) .buildContextParameter() return api.createConfiguratorEntry() .createParameter(country, {"DE"})

Pricefx Studio then suggest the possible options in each case.

With this level of assistance, there are really only two important parts to remember:

  1. Use api.inputBuilderFactory() to start defining the input.

  2. After defining it, use the corresponding method to build the input:

For more examples, please take a look at the Configurators documentation.

 

Here is how you can use the input builders in the common logics:

if (api.isInputGenerationExecution()) { return api.inputBuilderFactory() .createOptionEntry("Country") .setLabel("Select Country") .setOptions(["CZ", "DE", "UK"]) .getInput() } else { return input.Country }

isInputGenerationExecution is supported from version 10.0. In older versions use isSyntaxCheck.

Found an issue in documentation? Write to us.

Â