You will use a Customer Picker Filter logic when you need to:
Limit the list of customers presented to the business user, when they click on:
The customer input field.
The customer group input field.
When the Logic Is Called
From Customer input field - automatically by the system, at the moment when the user opens the Customer picker.
From Customer Group input field - automatically by the system, at the moment when the user opens the Customer picker.
From a logic, by calling the method api.evalCustomerFilterLogic(). This could be useful, if you need to call one filter logic from inside another one - e.g., when combining more filter logic results together.
Note that formerly it was possible to build the product input field on the line item also by calling the method api.customer() in the Input Generation mode. There’s a version of the api.customer() method, which supports adding of the filter too - sample: api.customer("customerId", null, false, "CustomerInputFilter", salesOrganization).
Logic API
Logic Nature: customerInputFilter
Logic Type: Calculation/Pricing
Execution Types:
Standard - to calculate the filters to be used in the customer picker.
Information provided to the logic:
In the Standard mode:
Binding variable
filterFormulaParam
will contain the text provided, when the logic was called. Commonly, if more than one value was needed to pass via the param, the values are passed as a Map, which is encoded as JSON text. In such case, you will need to decode the string before using.In case it’s called from the input field, the value of filterFormulaParam is provided in the definition of the input field.
When called from api.evalCustomerFilterLogic(), the value of the parameter is provided in the function call.
Expected logic execution outcome:
From Standard mode execution:
The system will collect the results of the logic elements, which return an object of type Filter (result values of other types are ignored). All those filters will be placed to a List and such List<Filter> will be used as a result of the logic.
Note that the Display Mode is ignored in this logic.
Sample
...
Sample of a logic of nature CustomerInputFilter
...
Code Block | |
---|---|
|
...
| |
def param = api.jsonDecode(filterFormulaParam)
def countryUnit = param?.CountryUnit
def custCorpGrpNo = param?.CustCorpGrpNo
List filters = []
if (countryUnit) {
filters.add(Filter.equal("attribute1", countryUnit))
}
if (custCorpGrpNo) {
filters.add(Filter.equal("attribute9", custCorpGrpNo))
}
if (filters.isEmpty()) {
return null
}
return Filter.and(*filters) |
...
Sample of definition of input field, which uses the filter logic
...
Code Block | |
---|---|
|
...
| |
Map filterParam = [
CountryUnit: countryUnit.getValue(),
CustCorpGrpNo: corpGrp.getValue()
]
def customerInputFieldBuilder = api.inputBuilderFactory()
.createCustomerEntry("Customer")
.setLabel("Customer")
.setFilterFormulaName("CustomerPickerFilter") //❶
.setFilterFormulaParam(api.jsonEncode(filterParam)) |
❶ Name of the CustomerInputFilter logic.
Info |
---|
See also Product & Customer Groups |