-
-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added new Apex method & JS function Logger.setField() #772
Conversation
d94f120
to
8356672
Compare
812f502
to
8bdcb3b
Compare
That was fast and the changes look great! If I understand correctly, if I do |
@surajp at the moment, that scenario would have slightly different behavior, depending on when you use the Example 1:Logger.setField(LogEntryEvent__e.My_Custom_Field__c,'value1');
// This entry will have 'value1'
Logger.info('an entry that does not use the builder setField() method);
// This record will have 'value2'
Logger.info('some message').setField(LogEntryEvent__e.My_Custom_Field__c,'value 2'); In this case, the first entry would have Example 2Logger.setField(LogEntryEvent__e.My_Custom_Field__c,'value1');
// This entry will have 'value2'
Logger.info('some entry that overrides the same field set via static method Logger.setField()').setField(LogEntryEvent__e.My_Custom_Field__c,'value 2'); In this case, since the first entry would have I think this behavior makes sense, but let me know what you think about it. At the very least though, I'll want to document the behavior so people understand how it works in these situations. |
… be set once per transaction --> auto-populated on all LogEntryEvent__e records
8bdcb3b
to
e1b3c0a
Compare
…ce, using logger.setField()
e1b3c0a
to
9d437dd
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #772 +/- ##
==========================================
- Coverage 92.82% 92.77% -0.05%
==========================================
Files 75 75
Lines 7203 7229 +26
Branches 190 191 +1
==========================================
+ Hits 6686 6707 +21
- Misses 498 503 +5
Partials 19 19
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
New Apex Method
Logger.setField()
Resolved #769 by adding a new static method,
Logger.setField()
. This gives Apex developers a way to set field(s) once per transaction, and the fields will be auto-populated on allLogEntryEvent__e
records generated in that transaction.The
setField()
method has 2 overloads (same as the instance method overloadsLogEntryEventBuilder.setField()
that were introduced in releasev4.13.14
)Logger.setField(Schema.SObjectField field, Object fieldValue)
- useful for easily setting the value for a single fieldLogger.setField(Map<Schema.SObjectField, Object> fieldToValue)
- useful for setting the value for multiple fieldsThe new method supplements the functionality introduced in release
v4.13.14
, as shown below:New JavaScript Function
logger.setField()
Added JavaScript support for setting fields once per component instance, using
logger.setField()
. This is the JS equivalent of the new Apex methodLogger.setField()
(above).