Skip to content
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

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

Open
jongpie opened this issue Feb 6, 2024 Discussed in #625 · 4 comments
Open

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

jongpie opened this issue Feb 6, 2024 Discussed in #625 · 4 comments
Assignees
Labels
Layer: Log Management Items related to the custom objects & Logger Console app Logging Source: Flow Items related to using Nebula Logger within Flow Salesforce Feature: Reporting Anything related to reports, dashboards, and the underlying data model Type: Enhancement New feature or request

Comments

@jongpie
Copy link
Owner

jongpie commented Feb 6, 2024

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 jongpie added Type: Enhancement New feature or request Salesforce Feature: Reporting Anything related to reports, dashboards, and the underlying data model Logging Source: Flow Items related to using Nebula Logger within Flow Layer: Log Management Items related to the custom objects & Logger Console app labels Feb 6, 2024
@jongpie jongpie self-assigned this Feb 6, 2024
@samphif
Copy link

samphif commented Jun 7, 2024

I agree this would be a useful feature to have.

@pcc-ferror
Copy link

@jongpie I noticed that when logging in a scheduled flow, the flow will encounter an exception due to the ParentLogTransactionId__c being missing (I assume based on the exception message below)... Is there any way around this to save the logs in the scheduled flow without setting it? I am using the apex-FlowRecordLogEntry apex action.

I am using version 4.13.11 of the unlocked package for what its worth.

System.SObjectException: Field is not writeable: LogEntryEvent__e.ParentLogTransactionId__c
Class.Logger.finalizeEntry: line 3392, column 1
Class.Logger.saveLog: line 3219, column 1
Class.Logger.saveLog: line 3177, column 1

@jongpie
Copy link
Owner Author

jongpie commented Sep 27, 2024

Hi @pcc-ferror, thanks for reporting that error! I haven't seen that issue before, though I don't work with scheduled flows much - I'll try to reproduce it, but any chance you're able to reproduce the issue in a sandbox? If so, I might have 1 or 2 ideas we could try to fix it.

@pcc-ferror
Copy link

@jongpie It looks like its working now hahaha... I just activated the scheduled flow to run again this morning and it worked... This was in a sandbox... I'll keep an eye on it in production to see if it can be reproduced.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Layer: Log Management Items related to the custom objects & Logger Console app Logging Source: Flow Items related to using Nebula Logger within Flow Salesforce Feature: Reporting Anything related to reports, dashboards, and the underlying data model Type: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants