- 23 May 2024
- 1 Minute to read
- Print
- DarkLight
Filter Account List
- Updated on 23 May 2024
- 1 Minute to read
- Print
- DarkLight
Purpose
Allows you to run a script that filters the list of accounts that are shown when creating a quote.
Setup
Upload the script for Filter Account List.
For details about uploading and configuring Groovy scripts, read Upload a Groovy script.
Binding variables
In addition to the common binding variables, the following binding variables are available for this extension point.
Variable name | Class | Description |
---|---|---|
filterAccountScript | Collection<Condition> | Set of filter conditions that apply to the account list |
filterFactory | FilterFactory | Helper class for creating the conditions |
Expected output
The script fills in the filterAccountScript variable with the appropriate conditions, which are then used to filter the account list for quote creation.
Conditions may be created with the help of the filterFactory variable or instantiated directly by the script. Refer to the Javadoc for available subtypes of the Condition interface that can be added to the filterAccountScript variable.
If multiple conditions are added, the account must meet all of them to pass the filter. There is currently no support for OR operation for multiple conditions. Within one condition, however, it is often possible to specify multiple inputs; these are evaluated as either-or, as illustrated by the following script snippet:
// include only accounts that belong to either Automotive or Manufacturing industry
def condition1 = filterFactory.getCondition(Schema.Industry, Schema.hasIndustry,
Schema.objectName, ["Automotive", "Manufacturing"], OPERATOR.CONTAINS);
filterAccountScript.add(condition1);
// include only accounts that has "GRP1" account group
def condition2 = new ConditionAttribute(Schema.accountGroup, "GRP1",
OPERATOR.CONTAINS);
filterAccountScript.add(condition2);
def attribute Chain = Lists.newArrayList(//
Pair.of(Schema.definesSalesInfo, Schema.SalesInfo),//
Pair.of(Schema.hasSalesOrg, Schema.SalesOrg));
Condition c = filterFactory.getConditionChain(//
attributeChain, filterFactory.getCondition(Schema.objectERPId, "1000", OPERATOR.EQUAL));
filterAccountScript.add(c);
// only accounts that meet both of these conditions are shown in quote creation
Script execution
The script runs automatically when a new quote is created through the user interface. The list of accounts that can be selected in the Create Quote screen are filtered according to the script.
If no script is uploaded for this extension point, or the script has an error, the system makes all accounts available for selection (the default behavior).