Skip to content

Using RFLIB in a Managed Package

Johannes Fischer edited this page May 22, 2022 · 1 revision

RFLIB is optimized for deployments into customer orgs. The unlocked packages allows for an easy installation and still gives clients or SIs the opportunity to apply code changes without having to open a ticket as it would be needed for a Managed Package.

Having said all of that, RFLIB is perfectly suited to be incorporated into any Managed Package. I would event recommend ISVs to strongly consider it, because with the dependency injection (DI) that the tool uses, you can configure the library to use logger of the customer org to merge managed package logs with the client log statements without requiring subscriber access. This would allow clients of your Managed Package to investigate more easily if their customizations are causing any trouble within the Managed Package.

However, in order to incorporate RFLIB in a managed package, the code must be adjusted so that it becomes part of the namespace of the Managed Package.

Adjusting the RFLIB Code Base for Use in a Managed Package

Salesforce will automatically add the namespace to objects, fields, classes, components, etc. But RFLIB uses references to those fields in the frontend code of the Ops Center components, and these references will not be automatically adjusted.

DISCLAIMER I have not yet had the chance to do incorporate RFLIB into a managed package. All steps below are provided as a "best guess" of all the work that is needed, but is not guaranteed to be complete.

In the namespace Org, you need to use the org's namespace prefix for all custom fields of the platform event. Update the following components:

  • rflibLogEventList
  • rflibLogEventListRow
  • rflibLogEventViewer

For the rflibLogEventViewer and rflibLogEventListRow components, add the namespace prefix to the fields. For example:

<lightning-formatted-text value={logEvent.Log_Messages__c}> needs to be updated to <lightning-formatted-text value={logEvent.YourNamespacePrefix__Log_Messages__c}>

In the rflibLogEventList, one may need to update the search function:

// RFLIB 4.0 - rflibLogEventList.js - line 91
const filteredEvents =
            this.contextSearch || this.createdBySearch || this.logMessageSearch
                ? this.allEvents.filter(
                      (evt) =>
                          (!this.createdBySearch || evt.CreatedById.indexOf(this.createdBySearch) > -1) &&
                          (!this.contextSearch || evt.YourNamespacePrefix__Context__c.indexOf(this.contextSearch) > -1) &&
                          (!this.logMessageSearch || evt.YourNamespacePrefix__Log_Messages__c.indexOf(this.logMessageSearch) > -1)
                  )
                : this.allEvents;
Clone this wiki locally