Skip to content

Getting Started with Logging in OmniStudio

Johannes Fischer edited this page Dec 18, 2024 · 9 revisions

RFLIB Logging can be used in Salesforce OmniStudio's OmniScript and Integration Procedures. This enables continuous monitoring and troubleshooting of these tools in production environments, 24/7.

Logging in Integration Procedures (IP)

Integration Procedures (IP) are the interface between guided experiences and your data. And since data is often at the center of any issues, it is critical to get insights into what is happening within your IPs during production. This is where RFLIB comes in, you can configure Remote Actions to send log messages to the framework. And since RFLIB maintains state within the transaction, anything that happens within the transaction of an IP will be logged. It is highly recommended to treat an IP like code, and log the input parameters, every path, and most importantly any errors.

To create a log message within an IP, follow the steps below:

  1. Drag the Remote Action component into the Integration Procedure structure
  2. Give it a name, i.e. "Log Invocation"
  3. Set the Remote Class to rflib_OmniStudioRemoteActions and the Remote Method to LogMessage
  4. Add Additional Input:
  • context: The common name for the log message that makes it easier to filter for in the dashboard.
  • level: The log level such as DEBUG, INFO, WARN, ERROR, or FATAL.
  • message: The actual log message, which can include expressions.

It is recommended to also check the Send Only Additional Input checkbox.

OmniStudio IP Logging

Using this approach with honor all Logger Settings configuration values that the framework comes with and set all automatically populated values on the log messages.

Logging in IP TryCatchBlock

When using a TryCatchBlock in Integration Procedures, you can log the error but not provide any arguments to the logger. Use the LogFailure method in this case, which will create an ERROR log message and handle the input provided by OmniStudio properly. The screenshot below shows the proper setup.

OmniStudio IP TryCatchBlock

Logging in OmniScripts (OS)

Similar to integration procedures, you can log messages from OmniScripts (OS). However, at this time, every configured Remote Action will only log the configured message, not the stack. It is therefore critical to include as much state of the OmniScript as possible in the message to make the single message more meaningful.

To add a log message to your script, follow the steps below:

  1. Select the "Build" tab.
  2. Drag the "Remote Action" component into your script layout.
  3. Give it a name, i.e. "Log Invocation"
  4. Set the "Invoke Method" to Fire and Forget
  5. Set the Remote Class to rflib_OmniStudioRemoteActions and the Remote Method to LogMessage

OmniStudio OS Logging Properties

  1. Add Extra Payload:
  • context: The common name for the log message, i.e. the name of the OmniScript.
  • level: The log level such as DEBUG, INFO, WARN, ERROR, or FATAL.
  • message: The actual log message, which can include expressions.

It is recommended to also check the Send Only Extra Payload checkbox.

OmniStudio OS Logging Payload

Application Events Logging

Application Events can be logged in OmniScript and in Integration Procedures using the Remote Action component. Keep in mind that those are less for investigations, but meant to be used for creating business insights. For example, issue an Application Event at the beginning of an OmniScript and at the end to determine how many times users started the OS but did not finish it. Application Events for errors is also a good option to make it easier to tracking purposes within the Application Event Dashboard.

To send out an Application Event, follow below steps:

  1. Select the "Build" tab.
  2. Drag the "Remote Action" component into your script layout.
  3. Give it a name, i.e. "My OS Start"
  4. Set the "Invoke Method" to Fire and Forget
  5. Set the Remote Class to rflib_OmniStudioRemoteActions and the Remote Method to LogApplicationEvent

OmniStudio OS App Event Properties

  1. Add Extra Payload:
  • context: The common name for the log message, i.e. the name of the OmniScript.
  • level: The log level such as DEBUG, INFO, WARN, ERROR, or FATAL.
  • message: The actual log message, which can include expressions.

It is recommended to also check the Send Only Extra Payload checkbox.

OmniStudio OS App Event Payload

Recommended Practices

The following bullets represent my thoughts on how to use RFLIB in OmniStudio. These are just suggestions and I would love to hear more ideas on how to better use the framework. Here are my thoughts:

  • In OmniScripts, add an Application Event for the start and the finish of the script. This applies to sub script representing full processes as well
  • In OmniScripts, add an Application Event before any steps displaying error pages
  • In OmniScripts, log an ERROR message before any steps displaying error pages
  • In Integration Procedures, log inputs specifically when coming from OmniScript at INFO level
  • In Integration Procedures, log every condition path using the INFO level
  • In Integration Procedures, log the result before returning it to the client
  • In Integration Procedures, use try-catch in Integration Procedures and log ERROR messages within the catch block
  • In Integration Procedures, use Application Events sparingly. If the IP returns data to an OS, it would be more valuable to log the Application Event on the OS side if needed.
Clone this wiki locally