Skip to content

Instantly share code, notes, and snippets.

@jongpie
Created September 14, 2022 19:11
Show Gist options
  • Save jongpie/dac91dec58b8aee9426fea2f0daae087 to your computer and use it in GitHub Desktop.
Save jongpie/dac91dec58b8aee9426fea2f0daae087 to your computer and use it in GitHub Desktop.
Nebula Logger - custom field mapping
public without sharing class CustomNebulaLoggerMapping {
@InvocableMethod
public static void mapCustomFields(List<Nebula__LogEntryEvent__e> events) {
// Build up the list of event UUIDs
List<String> eventUuids = new List<String>();
for (Nebula__LogEntryEvent__e event : events) {
eventUuids.add(event.EventUuid);
}
// Query the relevant Log Entry records
Map<String, Nebula__LogEntryEvent__e> uuidToEvent = new Map<String, Nebula__LogEntryEvent__e>();
for (Nebula__LogEntry__c logEntry : [SELECT Id, EventUuid__c FROM Nebula__LogEntry__c WHERE EventUuid__c IN :eventUuids]) {
uuidToEvent.put(logEntry.EventUuid__c, logEntry);
}
// Update them
for (Nebula__LogEntryEvent__e event : events) {
Nebula__LogEntry__c logEntry : uuidToEvent.get(event.EventUuid);
logEntry.My_Field__c = event.My_Field__c;
}
update uuidToEvent.values();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment