--- title: "Pre-Entry Field Options Filterer" slug: "pre-entry-field-options-filterer" updated: 2023-06-27T14:49:04Z published: 2023-06-27T14:49:04Z canonical: "docs.zilliant.com/pre-entry-field-options-filterer" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.zilliant.com/llms.txt > Use this file to discover all available pages before exploring further. # Pre-Entry Field Options Filterer This Apex hook controls the list of options shown in the picklist of a **Pre-entry** field. If the hook is not applied, then all **Picklist** values appear in the dropdown. The input for this hook includes the list of all pre-entry fields configured for this component, along with any current entered user value. This allows the hook to filter the **Picklist** of the current pre-entry field based on the values of previously entered pre-entry fields. For example, assume you have two pre-entry fields: **State** and **City**. The **State** pre-entry field is a controlling field for the **City** pre-entry field. Each time the user changes the state pre-entry field, new options for the city pre-entry field are presented. This Apex hook occurs before a **Pre-entry** field of type **Picklist** is displayed to a user on the **Add Lines** component. ## Apex hook class - It must implement the **zpl.PreEntryFieldOptionsFilterer** interface. - It must have a global access modifier. - You must specify the Apex hook class name in the **Pre-entry Field Options Filterer** field of the **Product Selector Configuration**. ## Interface definition ``` /**  * Interface for the hook class for filtering picklist options in configured pre-entry fields.  *  * @param currentField the pre-entry field for which the list of available options is configured  * @param defaultFieldOptions default list of options for the current pre-entry field  * @param allFields list of the pre-entry fields configured in the system  * @param valuesBySalesforceFieldName map of the user-entered values for the each pre-entry field defined.  *                  KEY: API name of the pre-entry field (SalesforceField__c), VALUE: user-entered field value  * @param headerRecordId the ID of current Header object record (ID of Contract or Price Lookup record)  * @returns a new list of options that will be displayed to user for selection for the current pre-entry field.  */ global interface PreEntryFieldOptionsFilterer {     List getFilteredOptions(             zpl__PreEntryField__c currentField,             List defaultFieldOptions,             zpl__PreEntryField__c[] allFields,             Map valuesBySalesforceFieldName,             Id headerRecordId); } ``` ## Example of the class implementation ``` global with sharing class SimplePreEntryFieldOptionsFilterer implements zpl.PreEntryFieldOptionsFilterer {     private static final String STATUS_CONTRACT_LINE_ITEM_FIELD = Schema.SObjectType.zpl__ContractLineItem__c.fields.zpl__Status__c.getName();     private static final String EFFECTIVE_DATE_CONTRACT_LINE_ITEM_FIELD = Schema.SObjectType.zpl__ContractLineItem__c.fields.zpl__EffectiveDate__c.getName();     private static final String WAREHOUSE_PREFERENCE_CONTRACT_LINE_ITEM_FIELD = Schema.SObjectType.zpl__ContractLineItem__c.fields.WarehousePreference__c.getName();     global List getFilteredOptions(zpl__PreEntryField__c currentField, List defaultFieldOptions,             zpl__PreEntryField__c[] allFields, Map valuesBySalesforceFieldName, Id headerRecordId)     {         if (isStatusField(currentField) && isFutureEffectiveDate(valuesBySalesforceFieldName.get(EFFECTIVE_DATE_CONTRACT_LINE_ITEM_FIELD)))         {             List filteredPicklistOptions = new List();             for (zpl.PicklistValue picklistValue : defaultFieldOptions)             {                 if (picklistValue.value != 'Active')                 {                     filteredPicklistOptions.add(picklistValue);                 }             }             return filteredPicklistOptions;         }         if (isWarehousePreferenceField(currentField) && !isUserSystemAdministrator())         {             List filteredPicklistOptions = new List();             for (zpl.PicklistValue picklistValue : defaultFieldOptions)             {                 if (picklistValue.label.startsWith('N'))                 {                     filteredPicklistOptions.add(picklistValue);                 }             }             return filteredPicklistOptions;         }         return defaultFieldOptions;     }       private static Boolean isStatusField(zpl__PreEntryField__c currentField)     {         return currentField.zpl__SalesforceField__c == STATUS_CONTRACT_LINE_ITEM_FIELD;     }     private static Boolean isFutureEffectiveDate(Object effectiveDate)     {         return ((Date) effectiveDate) > Date.today();     }     private static Boolean isWarehousePreferenceField(zpl__PreEntryField__c currentField)     {         return currentField.zpl__SalesforceField__c == WAREHOUSE_PREFERENCE_CONTRACT_LINE_ITEM_FIELD;     }     private static Boolean isUserSystemAdministrator()     {         String userProfileName =         [                 SELECT Name                 FROM profile                 WHERE id =: UserInfo.getProfileId()         ].Name;         return userProfileName == 'System Administrator';     } } ```