HomeGuidesDeveloper HubRelease Notes
Get supportBook a chat
Developer Hub
These docs are for v2.56. Click to read the latest docs for v2.208.

FieloPLT.SObjectService Class

The FieloPLT.SObjectService class includes three methods.

Process Records (processRecords)

static void FieloPLT.SObjectService.processRecords (List<SObject> records, Map<Id, SObject> existingRecords)

Enables the Rules Engine to process records when they are both created and updated. Only records of objects which have undergone Rule Trigger configuration are processed.

Parameters

ParameterTypeDescription
recordsList<SObject>A list of records to process.
existingRecordsMap<Id, SObject>Previous records before their update. You should enter NULL when inserting records.
❗️

Records should be inserted in the database.

Return Value

TypeDescription
VoidVoid.
trigger Event on FieloPLT__Event__c (after insert, after update) {
     SObjectService.processRecords((List<FieloPLT__Event__c>) Trigger.new, Trigger.oldmap);      
}

Revert Records (revertRecords)

static Map<Id, String> FieloPLT.SObjectService.revertRecords (Set<Id> recordIds)

Lets you reverts a set of object IDs from records which are already processed. Processed records and all Transactions related to them are completely reverted.

🚧

You can only revert Transactions that gave Points but not the ones giving Instant Rewards and Badges.

Parameters

ParameterTypeDescription
recordIdsSet<Id>IDs of objects to be reverted.

Return Value

TypeDescription
Map<Id, String>Map of errors from records IDs. If operation is successful, value is an empty map.
❗️

Set IDs

Set of IDs must be from the same object.

Set<Id> eventIds = new Set<Id>();
for(FieloPLT__Event__c event : [SELECT Id FROM FieloPLT__Event__c LIMIT 10]){
     eventIds.add(event.Id);
}
Map<Id, String> resultsMap = FieloPLT.SObjectService.revertRecords(eventIds);
if(!resultsMap.isEmpty()){
    for(Id recordId : resultsMap.keySet()){
        ApexPages.addMessage(new ApexPages.Message(severity.ERROR, resultsMap.get(recordId)));
    }
}

Simulate Record Processing (processRecordsSimulator)

static Map<String, List<Sobject>> FieloPLT.SObjectService.processRecordsSimulator (List<SObject> records, Map<Id, SObject> existingRecords, Set<Id> memberIds)

Simulates how the Rules Engine processes records. Records are processed when they are both created and updated, as long as they meet the condition set in the Rule Trigger created for the object.

Parameters

ParameterTypeDescription
recordsList<SObject>Records to be processed.
existingRecordsMap<Id, SObject>Previous records before their update. They must be Null when inserting records.
memberIdsSet<Id>Set of Members IDs used to simulate record processing.

Return Values

TypeDescription
Map<String, List<Sobject>>Map of the inserted object API name
List<FieloPLT__Event__c> records = new List<FieloPLT__Event__c>();
records.add( new FieloPLT__Event__c(Name = 'test1', FieloPLT__Value__c = 100) );
Map<Id, SObject> existingRecords = new Map<Id, SObject>();
Set<Id> memberIds = new Set<Id>();
Map<String, List<Sobject>> FieloPLT.SobjectService.processRecordsSimulator(records, existingRecords, memberIds);