Published Feb 17

How to pass Header Input Values into Line Item Configurator

Helper article: https://pricefx.atlassian.net/wiki/display/KB/Pass+Values+between+Quote+Header+Logic,+Configurator+and+Line+Item+Logic

In order to pass Header Input values into the Line Item Configurator (we’ll use Formula Configurator, AGR_FormulaBasedPricing_FormulaConfigurator for this example) one needs to pass the clicId to the configurator logic.

In the Configurator creation method (where api.configurator/api.inlineConfigurator) is called we need to add a piece of code that will inject the configurator with the clicId of the currently calculated line item:

Map getFormulaConfigurator(Map inputs) { Map formulaConfiguratorConfig = libs.AGR_ProcessingLib.ConstConfig.AGREEMENT_LINE_ITEM_INPUTS.FORMULA_CONFIGURATOR Map configurator = api.inlineConfigurator(formulaConfiguratorConfig.NAME, formulaConfiguratorConfig.LOGIC_NAME) ContextParameter configuratorParameter = api.getParameter(formulaConfiguratorConfig.NAME) if(configuratorParameter != null && configuratorParameter.getValue() == null) { configuratorParameter.setValue([currentClicId: api.currentItem().clicId]) } return configurator }

The most important part are the lines from 6 to 9. They read the api.currentItem (which is the line item) and append the clicId (which we’ll use to retrieve the Header Inputs in the Configurator logic)

The next step would be to read the passed clicId value and use it to retrieve the inputs, for example in the Formula Configurator logic we’re creating the formula Options dropdown, let’s use this and access the value there.

ConfiguratorEntry getFormulaInput(Map inputs) { Map formulaInputConfig = libs.AGR_ProcessingLib.ConstConfig.AGREEMENT_LINE_ITEM_INPUTS.FORMULA_CONFIGURATOR.INPUTS.FORMULA Integer currentAgreementId = api.input("currentClicId") Map currentAgreementInputs = libs.AGR_ProcessingLib.AgreementUtils.getAgreementInputs(currentAgreementId) //Here we can call a .find method on currentAgreementInputs to retrieve the input we want Map displayReadyFormulas = getDisplayReadyApprovedFormulas() List displayReadyFormulasUniqueNames = displayReadyFormulas.keySet() as List ContextParameter formulaContextParameter = api.inputBuilderFactory() .createOptionEntry(formulaInputConfig.NAME) .setLabel(formulaInputConfig.LABEL) .setHelpText(formulaInputConfig.HELP_TEXT) .setPlaceholderText(formulaInputConfig.PLACEHOLDER) .setOptions(displayReadyFormulasUniqueNames) .setLabels(displayReadyFormulas) .setRequired(true) .buildContextParameter() return libs.AGR_InputLib.CommonInputGenerationUtils.buildConfiguratorEntry(formulaContextParameter) }

Lines from 3 to 7 tell how to access the passed value and how to retrieve the Header inputs Map. This Map contains definitions for all inputs on the Header with their values included.

In the helper article mentioned at the beginning, this method states that it’s only good when the value is passed “only once as an initialization step” - this is fine, because the clicId will not change throughout the lifecycle of the Agreement.

If the clicId would somehow disappear from the Configurator logic after it has been passed a Hidden Input with “noRefresh” set to true, can be used to store its value to prevent the loss.

Related content