Created
September 14, 2022 19:11
-
-
Save jongpie/dac91dec58b8aee9426fea2f0daae087 to your computer and use it in GitHub Desktop.
Nebula Logger - custom field mapping
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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