Data Loader
The Breezz framework enables the creation of Data Loaders, particularly useful when more complex queries are needed which cannot be covered by getStore().requestToLoad()
method. In scenarios where records require filtering using different WHERE clauses, Data Loaders become invaluable, allowing the gathering of specific data sets tailored for unique business logic implementations.
To configure Breezz Data Loader we need to go Breezz Setup → Data Loaders → New.
Fields Details:
- Name - the name of data loader configuration (aka storeKey)
- Feature Availability - determines feature availability, see this page for more details
- Is Active - determines if the Data Loader is active
- Configuration Type - type of the Data Loader configuration, options are:
- Query - requries building Query withing Data Loader configuration
- Custom - requires Data Loader Class Name
- Is Global - determines if results will be stored in the global store (Data will be loaded only once in the entire transaction)
- Query - available only for Query data loader type, contains a SOQL query that determines which records should be loaded. Useful operator is In Keys/Not In Keys which allows filtering records by key, which can be set in apex requestToLoad methods.
- Data Loader Class Name - available only for Custom data loader type, requires provding an Apex implementation of Custom Data Loader
- Result transformation - data loader is capable of returning data in 3 different forms and this form is determined by Result Transformation picklist value which can be:
- None - meaning that single record or list of records are returned
- List -> Map Grouped By Field Value - meaning that list if records returned by the query is transformed into the Map<key, record> where key is defined by Group By Field Name input field
- List -> Map of Lists Grouped By Field Value - meaning that list if records returned by the query is transformed into the Map<key, list<records>> where key is defined by Group By Field Name input field
- Group by Field Name - key used to group records returned by the query when Result Transformation is different from None
Query Builder:
The query builder stands out due to its wide range of options for filtering records based on the criteria we want to obtain. Various operators and different value providers are available:
- supported operators: Equals, Does Not Equal, Is Null, Is Not Null, Less Than, Less Than or Equal, Greater Than, Greater Than or Equal, In, Not In, Like, Not Like, In Keys, Not In Keys
- keys utilized by In Keys or Not In Keys can be set in Apex using one of the requestToLoad methods.
- supported value types: Value, $Record, $User, $UserRole, $Profile, $Organization, $System, $RecordType, $CustomPermission, $Label, custom settings
Advanced Query Builder
Advanced Query Builder allows providing query manually. SOQL query determines which records should be loaded. The :keys variable can be used in the query - variable contains keys of the records to be loaded
Keep in mind, the Advanced Query Builder does not cover all SOQL aspects. Things like GROUP BY, ALL ROWS, and ALL FIELDS won’t work. Plus, it won’t handle inner queries.
Custom Data Loader
Custom Data Loader must be associated with an Apex class that extends the forvendi.DataStore.Loader abstract class and overrides load method. Generating this custom data loader code is straightforward. Simply navigate to: Breezz App → Breezz Setup → Datga Loader → and Generate Loader Code button.
The logic is as follows:
1public with sharing class CustomDataLoaderClassName extends forvendi.DataStore.Loader {
2 public CustomDataLoaderClassName() {
3 super('DataLoaderName', false);
4 }
5
6 public override void load(forvendi.DataStore store) {
7 // add data loader logic
8 // for example:
9 if (store.notInStore(storeKey)) {
10 Map<Id, List<Task>> tasksByCaseId = new Map<Id, List<Task>>();
11 for (Task task : [SELECT Id, WhatId FROM Task WHERE WhatId IN :store.getIds(storeKey)]) {
12 if (!tasksByCaseId.containsKey(task.WhatId)) {
13 tasksByCaseId.put(task.WhatId, new List<Task>());
14 }
15 tasksByCaseId.get(task.WhatId).add(task);
16 }
17 store.storeData(storeKey, tasksByCaseId);
18 }
19 // you cannot use DMLs and Async Apex code invocations
20 }
21}
DataLoaderName is a value of the storeKey variable. Its value is supposed to match the name of a custom data loader configured in Breezz UI.
StoreKey can be used in getFromStore method to access custom data loader query results.