Filtering Records for Salesforce Listener
I am trying to confirm that the approach I'm taking is officially supported and documented by Celigo.
I'm using a trigger handler in Salesforce to filter my records before calling integrator_da__.RealTimeExporter.processExport(). However, I am sending the following parameters:
recordList = a Salesforce list of sObjects whose type match the type of the Celigo Listener
flowHandles = a Salesforce list of strings with the appropriate (ie mapped to the specific Celigo Listener(s) needed) GUID value(s) from the Real Time Sync records in Salesforce
connectorId = a manually set value by a Salesforce admin on the appropriate Real Time Sync records
So, my call now looks like this: integrator_da__.RealTimeExporter.processExport(recordList, flowHandles, connectorId)
This is working well for me and allows me to truly filter the list of records that the Listener is receiving. I am asking for official documentation because the only reference I found to this was in a single community post. Thank you Jérémie Denis for sharing your solution in the community! It is the only reason I was able to get this working.
However, in two posts, there are references that processExport() either takes 0 parameters or 1 parameter. If this design is not officially supported or documented, I'd like some guidance on how to reliably only deliver records whose value has changed to the Listener. In Celigo, the filtering only allows for current value evaluation. My use case, though, is that we only want an action to be triggered when a record previously “in compliance” changes to “out of compliance.”
For reference, here are the relevant snippets of my code
Trigger
trigger CaseTrigger on Case (after update) {
if(Trigger.isUpdate) {
CaseTriggerHandler.afterUpdate(Trigger.oldMap, Trigger.newMap);
}
}
TriggerHandler
public with sharing class CaseTriggerHandler {
public static void afterUpdate(Map<Id, Case> oldRecords, Map<Id, Case> newRecords) {
Map<Id,Case> outOfComplianceRecords = new Map<Id,Case>();
for (Id recordId : newRecords.keySet()) {
if(newRecords.get(recordId).Out_of_Compliance__c &&
!oldRecords.get(recordId).Out_of_Compliance__c) {
outOfComplianceRecords.put(recordId,newRecords.get(recordId));
}
}
if(outOfComplianceRecords.isEmpty()) {
System.debug('No out of compliance Cases found.');
return;
} else {
System.debug('Out of compliance Cases found: ' + outOfComplianceRecords.keySet());
celigoTrigger(outOfComplianceRecords);
}
}
public static void celigoTrigger(Map<Id,Case> outOfComplianceRecords) {
/*
Real_Time_Sync__c records are created by Celigo when a Listener connection is created.
These records reflect the definition of the Listener in Celigo and enables us to
manage the filtering entirely and send a curated set of records to the webhook.
*/
// Salesforce admin will manually set Connector Id values on Real_Time_Sync__c record
String connectorId = 'Case_Listener_Id';
List<integrator_da__Real_Time_Sync__c> celigoSyncList = [SELECT Id, integrator_da__GUID__c, integrator_da__Connector_Id__c
FROM integrator_da__Real_Time_Sync__c
WHERE integrator_da__Connector_Id__c = :connectorId];
// GUID values below are set by Celigo upon creation of Real_Time_Sync__c record
List<String> flowHandles = new List<String>();
for (integrator_da__Real_Time_Sync__c sync : celigoSyncList) {
flowHandles.add(sync.integrator_da__GUID__c);
}
// Making this callout sends our filtered list of records to the appropriate Listener in Celigo
integrator_da__.RealTimeExportResult res = integrator_da__.RealTimeExporter.processExport(outOfComplianceRecords.values(), flowHandles, connectorId);
}
}
Comments
The supported method signatures for
processExport()
are as follows:processExport()
This method triggers the export without requiring any parameters.
processExport(List<String> flowHandles, String connectorId)
This method allows you to trigger the export by passing the
flowHandles
andconnectorId
parameters.processExport(List<SObject> l, List<String> flowHandles, String connectorId)
This method supports sending a list of Salesforce
SObject
records (i.e.,recordList
), along with theflowHandles
andconnectorId
.processExport(String connectorId)
This method allows triggering the export using only the
connectorId
.Your approach of manually filtering the records before calling
processExport()
should work well, as it aligns with the third signature where you passrecordList
,flowHandles
, andconnectorId
. In Celigo, record filtering can only be based on current values, as you mentioned, when qualification criteria is provided. Given your use case, the approach you've followed seems appropriate. Please do let us know if you face any challenges or in case of any queries.Thank you for the confirmation, SAMANTHULA SRI SATYA SANTOSH KUMAR ! I'll continue forward as planned!
Please sign in to leave a comment.