CDT Scoped Records Filterer Class
  • 29 Jun 2023
  • 1 Minute to read
  • Dark
    Light

CDT Scoped Records Filterer Class

  • Dark
    Light

Article summary

This Apex hook is specific to the Zilliant-developed Configurable Data Table component. The hook uses the context of a deal, a user, and each line to determine which line should be shown to a specific user in that current instance of the Configurable Data Table view.

The hook occurs when a specific Configurable Data Table instance is displayed to a user and controls the records the user sees in the component.

Apex hook class

  • It must implement one of the following two interfaces:
    • RecordsFilterer
    • ScopedRecordsFilterer
  • It must have a global access modifier.
  • You must specify the Apex hook class name in the Record Filterer Class Name field of the Extension Point Configuration for the Configurable Data Table component.

ScopedRecordsFilterer interface definition

/**
 * Interface for a hook class that encapsulates custom filtering logic on records for a Data table.
 * This version of the interface extends RecordsFilterer to add the option to include scoping restrictions.
 * To ignore scope, use LineItemsFilterer directly.
 */
global interface ScopedRecordsFilterer extends RecordsFilterer
{
    /**
     * @param headerRecordId the ID of current Header object record
     * @param scope map of system-defined values by which to constrain the available records
     *       KEY: name of the scoping element, VALUE: value of the scoping element
     *
     * @returns a condition that should be used on selecting records.
     */
    zal.Condition getScopedFilterCondition(Id headerRecordId, Map<String, Object> scope);
}

RecordsFilterer interface definition

/**
 * Interface for a hook class used to build a custom filter condition for the records displayed on a data table.
 *
 * @param headerRecordId the ID of current Header object record
 * @return a condition used when displaying records on a data table.
 */
global interface RecordsFilterer
{
    zal.Condition getFilterCondition(Id headerRecordId);
    

Example: ScopedRecordsFilterer implementation

public class RecordFiltererScopeDummy implements ScopedRecordsFilterer
{
    public zal.Condition getFilterCondition(Id headerRecordId)
    {
        return null;
    }
 
    public zal.Condition getScopedFilterCondition(Id headerRecordId, Map<String, Object> params)
    {
        zal.OrCondition andCondition = new zal.OrCondition();
        zal.OrCondition orcondition = new zal.OrCondition();
        orcondition.add(new zal.FieldCondition('Name').likex('%' + params.get('param1')));
        orcondition.add(new zal.FieldCondition('Name').likex('%' + params.get('param2')));
        andCondition.add(orcondition);
        andCondition.add(new zal.FieldCondition('zpl__Cost__c').greaterThan(5));
        return andCondition;
    }
}

Example: RecordsFilterer implementation

public class RecordFiltererDummy implements RecordsFilterer
{
    public zal.Condition getFilterCondition(Id headerRecordId)
    {
        zal.OrCondition condition = new zal.OrCondition();
        condition.add(new zal.FieldCondition('Name').likex('Next%'));
        condition.add(new zal.FieldCondition('Name').likex('WW%'));
        return condition;
    }
}


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.