-
-
Notifications
You must be signed in to change notification settings - Fork 200
[WIP] Custom Field Mappings
Since v4.13.14
, Nebula Logger provides the ability to add your own custom fields to its included custom objects. This is helpful in orgs that want to extend Nebula Logger's included data model by creating their own org/project-specific fields.
To start using custom field mappings, there are 4 steps:
- Add a custom field on
LogEntryEvent__e
(using whatever data type you want). - Add a corresponding custom field on either
Log__c
orLogEntry__c
. - Create a mapping record in
LoggerFieldMapping__mdt
. - Set your custom fields in code when logging.
Note
Note: this functionality currently only works in Apex & JavaScript. Flows & OmniStudio can't currently use this feature.
- Issue #719 is for adding equivalent functionality for Flow
- Issue #861 is for adding equivalent functionality for OmniStudio
To get started, the first step is to add a field to the platform LogEntryEvent__e`
-
Create your own custom fields on
LogEntryEvent__e
. Any data type supported by platform events can be used.-
In this example, a custom text field called
SomeCustomField__c
has been added:
-
-
Populate your own custom fields in Apex by calling one of the two new instance methods on
LogEntryEventBuilder
:setField(Schema.SObjectField field, Object fieldValue)
setField(Map<Schema.SObjectField, Object> fieldToValue)
For now, this functionality is available in Apex. Long-term, equivalent functionality will hopefully be added for Flow & Lightning Components. Here is an example of using the 2 new methods in Apex:
Logger.info('hello, world')
// Set a single field
.setField(LogEntryEvent__e.SomeCustomTextField__c, 'some text value')
// Set multiple fields
.setField(new Map<Schema.SObjectField, Object>{
LogEntryEvent__e.AnotherCustomTextField__c => 'another text value',
LogEntryEvent__e.SomeCustomDatetimeField__c => System.now()
});
If you want to store the data in one of Nebula Logger's custom objects, you can follow the above steps, and also...
-
Create an equivalent custom field on one of Nebula Logger's custom objects - right now, only
Log__c
,LogEntry__c
, andLoggerScenario__c
are supported. -
In this example, a custom text field also called
SomeCustomField__c
has been added toLog__c
object - this will be used to store the value of the fieldLogEntryEvent__e.SomeCustomField__c
: -
Create a record in the new CMDT
LoggerFieldMapping__mdt
to map theLogEntryEvent__e
custom field to the custom object's custom field, shown below. Nebula Logger will automatically populate the custom object's target field with the value of the sourceLogEntryEvent__e
field.-
In this example, a custom text field called
SomeCustomField__c
has been added to bothLogEntryEvent__e
andLog__c
.
-
TODO
Resolved #718 by adding the ability to set custom fields on a log entry in JavaScript (lightning components), using a new function setField()
in logEntryBuilder.js
. This is the JavaScript equivalent to the Apex method overloads setField()
in LogEntryEventBuilder.cls
that were introduced in release v4.13.14
.
-
To use the new
setField()
function, pass an object as the function's single parameter. The object should contain the custom fields onLogEntryEvent__e
that you want to set, along with their corresponding values. For example:{ SomeField__c": "some value", "AnotherField__c": "another value" }
import { createLogger } from "c/logger"; export default class LoggerCustomFieldDemo extends LightningElement { logger; async connectedCallback() { this.logger = await createLogger(); this.logger.info("Hello, world! This log entry has 2 custom fields set.") .setField({ SomeCustomTextField__c: "some text value", SomeCustomNumberField__c: 123, }); this.logger.debug("Hello again, world! This log entry has 1 other custom field set.") .setField({ AnotherCustomTextField__c: "another text value", }); this.logger.saveLog(); } }
- Assigning Permission Sets to Users
- Configuring Global Feature Flags
- Configuring Profile & User-Specific Settings
- Configuring Data Mask Rules
Manual Instrumentation
- Logging in Apex
- Logging in Flow & Process Builder
- Logging in Lightning Web Components & Aura Components
- Logging in OmniStudio
- Logging in OpenTelemetry (OTEL) REST API
ISVs & Package Dependencies
- Overview
- Optionally Use Nebula Logger (When Available) with
Callable
Interface - Require Nebula Logger with Strongly-Coupled Package Dependency
Troubleshooting
Pub/Sub with Platform Events
Persisted Data with Custom Objects
- Logger Console app
- Assigning & Managing Logs
- Using 'View Related Log Entries' Component on Record Pages
- Deleting Old Logs
Official Plugins