NebulaLogger icon indicating copy to clipboard operation
NebulaLogger copied to clipboard

Logging in Flow does not have a way to set a parent transaction ID

Open jongpie opened this issue 1 year ago • 4 comments

Currently, Apex developers can use these methods to link together Log__c records, providing traceability of a user's action across multiple related transactions.

  • Logger.setParentLogTransactionId(String)
  • Logger.getParentLogTransactionId()
  • Logger.getTransactionId()

Currently, Flow builders don't have an equivalent functionality. Nebula Logger's 3 Flow invocable logging classes - FlowLogEntry, FlowLogRecordEntry, and FlowCollectionLogEntry - don't currently have a way to set a parent transaction ID. This would be helpful to have for async Flows (including screen Flows & scheduled Flows) to provide the same type of traceability. See discussion 625 for more context.

To add this functionality, I think the Flow classes would need to have 3 equivalent enhancements

  • In the 3 invocable classes, add a new property String parentLogTransactionId as an equivalent to Apex's Logger.setParentLogTransactionId(String).
    • The class FlowLogger would then use the value of parentLogTransactionId and call Logger.setParentLogTransactionId(parentLogTransactionId) to store the value.
  • Create a new invocable Flow - LoggerFlowContext - that returns an instance of inner class (FlowOutput maybe?) with 2 properties
    • String logTransactionId - returns the value of Logger.getTransactionId()
    • String parentLogTransactionId - returns the value of Logger.getParentLogTransactionId()

I think this would provide feature parity between Apex logging & Flow logging for setting a parent Log__c.

jongpie avatar Feb 06 '24 16:02 jongpie

I agree this would be a useful feature to have.

samphif avatar Jun 07 '24 11:06 samphif