You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added new Apex method & JavaScript function Logger.setField() (#772)
* Added a new Apex static method Logger.setField() so custom fields can be set once per transaction --> auto-populated on all subsequent LogEntryEvent__e records
* Added new JavaScript function logger.setField() so custom fields can be set once per component instance --> auto-populated on all subsequent LogEntryEvent__e records
Copy file name to clipboardExpand all lines: README.md
+45-18Lines changed: 45 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,15 +5,15 @@
5
5
6
6
The most robust observability solution for Salesforce experts. Built 100% natively on the platform, and designed to work seamlessly with Apex, Lightning Components, Flow, OmniStudio, and integrations.
7
7
8
-
## Unlocked Package - v4.14.13
8
+
## Unlocked Package - v4.14.14
9
9
10
-
[](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015oW3QAI)
11
-
[](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015oW3QAI)
10
+
[](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015oWIQAY)
11
+
[](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015oWIQAY)
@@ -657,28 +657,55 @@ The first step is to add a field to the platform event `LogEntryEvent__e`
657
657
658
658

659
659
660
-
- In Apex, populate your field(s) by calling the instance method overloads `LogEntryEventBuilder.setField(Schema.SObjectField field, Object fieldValue)` or `LogEntryEventBuilder.setField(Map<Schema.SObjectField, Object> fieldToValue)`
660
+
- In Apex, you have 2 ways to populate your custom fields
661
661
662
-
```apex Logger.info('hello, world')
663
-
// Set a single field
664
-
.setField(LogEntryEvent__e.SomeCustomTextField__c, 'some text value')
665
-
// Set multiple fields
666
-
.setField(new Map<Schema.SObjectField, Object>{
667
-
LogEntryEvent__e.AnotherCustomTextField__c => 'another text value',
1. Set the field once per transaction - every `LogEntryEvent__e` logged in the transaction will then automatically have the specified field populated with the same value.
663
+
- This is typically used for fields that are mapped to an equivalent `Log__c` or `LoggerScenario__c` field.
664
+
665
+
- How: call the static method overloads `Logger.setField(Schema.SObjectField field, Object fieldValue)` or `Logger.setField(Map<Schema.SObjectField, Object> fieldToValue)`
666
+
667
+
2. Set the field on a specific `LogEntryEvent__e` record - other records will not have the field automatically set.
668
+
- This is typically used for fields that are mapped to an equivalent `LogEntry__c` field.
669
+
- How: call the instance method overloads `LogEntryEventBuilder.setField(Schema.SObjectField field, Object fieldValue)` or `LogEntryEventBuilder.setField(Map<Schema.SObjectField, Object> fieldToValue)`
670
+
671
+
```apex
672
+
// Set My_Field__c on every log entry event created in this transaction with the same value
673
+
Logger.setField(LogEntryEvent__e.My_Field__c, 'some value that applies to the whole Apex transaction');
674
+
675
+
// Set fields on specific entries
676
+
Logger.warn('hello, world - "a value" set for Some_Other_Field__c').setField(LogEntryEvent__e.Some_Other_Field__c, 'a value')
677
+
Logger.warn('hello, world - "different value" set for Some_Other_Field__c').setField(LogEntryEvent__e.Some_Other_Field__c, 'different value')
678
+
Logger.info('hello, world - no value set for Some_Other_Field__c');
679
+
680
+
Logger.saveLog();
670
681
```
671
682
672
-
- In JavaScript, populate your field(s) by calling the instance function `LogEntryEventBuilder.setField(Object fieldToValue)`
683
+
- In JavaScript, you have 2 ways to populate your custom fields. These are very similar to the 2 ways available in Apex (above).
684
+
685
+
1. Set the field once per component - every `LogEntryEvent__e` logged in your component will then automatically have the specified field populated with the same value.
686
+
- This is typically used for fields that are mapped to an equivalent `Log__c` or `LoggerScenario__c` field.
687
+
688
+
- How: call the `logger` LWC function `logger.setField(Object fieldToValue)`
689
+
690
+
2. Set the field on a specific `LogEntryEvent__e` record - other records will not have the field automatically set.
691
+
- This is typically used for fields that are mapped to an equivalent `LogEntry__c` field.
692
+
- How: call the instance function `LogEntryEventBuilder.setField(Object fieldToValue)`
Relates the current transaction's log to a parent log via the field Log**c.ParentLog**c This is useful for relating multiple asynchronous operations together, such as batch & queueable jobs.
0 commit comments