Help Center
  • What is GridMate
  • πŸ“ŒGetting Started
    • Package Setup
    • Appexchange
  • 🎬Product Tour
    • Related List Grid
    • Parent Related List Grid
    • List View Grid
    • Kanban List View Grid
    • Field Set Grid
    • User Grid
    • Pivot Grid
    • Report Table
    • Multi Calendar
    • Object Timeline
    • File Explorer
    • Record Layout
    • Record KPI
    • Field Path
    • Map Record
    • Map List
    • Utility Bar Grid
    • Record App Switcher
    • Flow Grids
    • Compact Calendar
  • πŸš€Advanced Guides
    • Grid - Advanced Configuration
    • Grid - Mass/Record Actions
    • Grid - Advanced Filtering
    • Grid - Inline Components
    • Grid - Mass Edit Button
    • Grid - Enhanced Filter Builder
    • Grid - Data Import Wizard
    • Grid - Dynamic Formula Field
    • Grid - Grid Explorer
    • Grid - Dynamic Interaction
    • Grid - Dynamic FieldSet Grid
    • Grid - Dynamic Record Card
    • Grid - Custom Action
    • Grid - Interactive Filters
    • Grid - Bulk Action
    • Grid - Custom Inline Component
    • Grid - Config Checker
    • Grid - Admin Cockpit
    • User Grid - Split View
    • User Grid - Data Filtering
    • User Grid - Deployment Process
    • Map List - Search Around Setup
    • Salesforce Classic Setup
  • πŸ“¦Package Reference
    • Components Library
      • GM - RelatedList Grid
      • GM - FieldSet Grid
      • GM - ListView Grid
      • GM - FieldSet Kanban
      • GM - ListView Kanban
      • GM - Parent RelatedList Grid
      • GM - RelatedList Tabs
      • GM - RelatedList Accordion
      • GM - RelatedList Cards
      • GM - Record Layout
      • GM - Record Layout (LWC)
      • GM - Record Card
      • GM - Dynamic Tabs
      • GM - Dynamic Accordion
      • GM - Flow Layout
      • GM - Field Path
      • GM - Multi Calendar
      • GM - FieldSet Pivot
      • GM - Flow View Grid
      • GM - Flow Edit Grid
      • GM - Record App Switcher
      • GM - Map Record
      • GM - Map List
      • GM - Report Table
      • GM - Object Timeline
      • GM - User Grid
      • GM - File Explorer
      • GM - Dynamic FieldSet Grid
      • GM - Dynamic Record Card
      • GM - User Grid Split View
      • GM - Compact Calendar
      • GM - Interaction Logger
    • Javascript Formulas
    • DataGrid Settings
  • Tools
    • SF Cli Plugin
    • Chrome Extension
  • πŸ“¬TROUBLESHOOTING
    • βš™οΈConfig Snippets
      • Layout - basic setup
      • Layout with read only field
      • Layout with field visibility
      • Layout with section visibility
      • Layout with autocomplete
      • Inline FieldSet Grid
      • Inline RelatedList Grid
      • Inline Record Layout
      • Inline Chatter Feed
      • Multiple Inline Components
      • Calendar - Extra Activities
      • Field Path Stages
      • Dynamic Tabs
      • Compact Calendar
      • Object Timeline
    • ❓FAQ
  • πŸ“‹Release Notes
Powered by GitBook

Links

  • Appexchange
  • Pricing
  • Solution

Social

  • Youtube
  • LinkedIn
  • X

2025 GridMate

On this page
  • Using Junctions
  • Using Inline SOQL
  • Using Parent Field
  • Using $USER
  • Using $CUSTOMSETTING
  • Using $APEX

Was this helpful?

  1. Advanced Guides

Grid - Advanced Filtering

Using Junctions

To filter the records either as an admin or as an end user can combine conditions with conjunctions like β€˜OR’, β€˜AND’. Below is a complex filter query:

{
   "or": [
      {
         "ParentId": {
            "operator": "=",
            "value": "$recordId"
         }
      },
      {
         "UltimateParent__c": {
            "operator": "=",
            "value": "$recordId"
         }
      }
   ]
}

$recordId can be used to implicitly use the current recordId

Using Inline SOQL

An inline SOQL query can be used to filter records within the current record. Inline SOQL can be used with β€œin” operator only:

{
   "Id": {
      "operator": "in",
      "value": "SELECT Project__c FROM Assignment__c WHERE Manager__c=$$recordId$"
   }
}

$$recordId$ can be used to implicitly use the current recordId in the SOQL query

Using Parent Field

Any field from the current object can be used to filter the related records. Parent fields can be referenced in the filter property as a merge field $record.fieldApiName

{
   "Country__c": {
      "operator": "=",
      "value": "$record.BillingCountry"
   }
}

Using $USER

Any field from the logged user can be used to filter the related records. User fields can be referenced in the filter property as a merge field $USER.fieldApiName

{
   "Amount": {
      "operator": "<",
      "value": "$USER.Minimum_Amount__c"
   }
}

Using $CUSTOMSETTING

Any field from any custom settings can be used to filter the related records. Custom settings fields can be referenced in the filter property as a merge field $CUSTOMSETTING.objectApiName.fieldApiName

{
   "Discount__c": {
      "operator": ">",
      "value": "$CUSTOMSETTING.Quote_Settings__c.Max_Discount__c"
   }
}

Using $APEX

For complex use cases, an apex class can be provided as a value provider for a filter property as a merge field $APEX.className({params})

{
   "Id": {
      "operator": "in",
      "value": "$APEX.AttachedDocumentFilter({\"recordId\":\"$recordId\"})"
   }
}

Apex class parameters should be always an escaped JSON string. $recordId can be used to implicitly use the current recordId.

The value provider class should implement a Callable interface and should be global. GridMate runs the value provider dynamically:

Callable handler = (Callable) Type.forName(handlerClass).newInstance();
return (String) handler.call('getValue', params);

The example below showcase a specific value provider to filter ContentVersion based on the current record:

global with sharing class AttachedDocumentFilter implements Callable {
    global Object call(String action, Map<String, Object> args) {
        if (action == 'getValue') {
            String recordId = (String) args.get('recordId');

            //Build the list of linked documents
            List<ContentDocumentLink> linkList = [
                SELECT Id, ContentDocument.LatestPublishedVersionId
                FROM ContentDocumentLink
                WHERE LinkedEntityId = :recordId
            ];

            List<Id> idList = new List<Id>();
            for (ContentDocumentLink link : linkList) {
                idList.add(link.ContentDocument.LatestPublishedVersionId);
            }

            return '(\'' + String.join(idList, '\',\'') + '\')';
        } else {
            throw new ExtensionMalformedCallException('Action not implemented');
        }
    }

    public class ExtensionMalformedCallException extends Exception {
    }
}
@isTest
class AttachedDocumentFilterTest {
    @testSetup
    static void createTestData() {
        ContentVersion content = new ContentVersion(
            Title = 'Demo Script',
            PathOnClient = '/demo_script.txt',
            VersionData = Blob.valueOf('Unit Test ContentVersion Body'),
            Origin = 'H'
        );

        insert content;
    }

    static testMethod void testExecute() {
        Test.startTest();

        Callable handler = (Callable) Type.forName('AttachedDocumentFilter').newInstance();
        String values = (String) handler.call(
            'getValue',
            new Map<String, String>{ 'recordId' => UserInfo.getUserId() }
        );

        Test.stopTest();

        System.assert(values != null);
    }
}
PreviousGrid - Mass/Record ActionsNextGrid - Inline Components

Last updated 1 year ago

Was this helpful?

πŸš€