NebulaLogger icon indicating copy to clipboard operation
NebulaLogger copied to clipboard

Logs not working in the Screen Flow

Open presottoAugusto opened this issue 1 year ago • 1 comments

Package Edition of Nebula Logger

Unlocked Package

Package Version of Nebula Logger

v4.7.8

New Bug Summary

I have successfully use Nebula Logger in our Autolaunched and Record-triggered flows, but when I try to use in a Screen Flow we lose the logs in the same transaction. Here's what I have: One Add Log Entry at the beginning saving that the flow has started, then we have some screen elements and subflows which also creates log entries. Then at the last two elements of the flow there is a final Add Log Entry and a Save Log action.

The result is only the lest Log Entry being logged, all the others, even the first one is not being logged anywhere.

So my question is, does Nebula Logger supports Screen Flows? I know that we're using Unique Transaction Id and it should be the same one.

presottoAugusto avatar Jun 30 '22 13:06 presottoAugusto

@presottoAugusto do you have any more details on how your flow is setup? Screen flows should work, so offhand, I'm not sure what could be causing your issue. For each of the log entries you're creating, are you specifying a value for the attribute "(Optional) Logging Level"? And within the custom settings LoggerSettings__c (there is also a custom tab called "Logger Settings"), what logging level do you have configured?

jongpie avatar Aug 09 '22 01:08 jongpie

Hey,

Screen flows work slightly different than normal flows. Each screen creates a new transaction. So if you add a log entry and save the log, everything is fine. If there is a screen in between, both action are running in a different transaction.

See the following example. There are two screens, so there are three transactions. Transaction 1: nothing interesting happening here Screen 1 Transaction 2: Log Entry is added, but Log not saved Screen 2: Transaction 2 is finished without saving -> no Log created Transaction 3: New transaction -> no entries added in this transaction yet -> save Log doesn't find any entries -> No log created image

This will work image

I think that this is no issue of the logger but based on the way Salesforce is running flows. We had the same issue with a different framework.

Hope that helps :)

fentes avatar Aug 25 '22 16:08 fentes

Oooooh thank you @fentes !! I had forgotten that each screen counted as a separate transaction... let me see if I can setup a similar Flow, and come up with some guidelines on how to make logging work with multiple different screens. Once I have an example working, I'll create a wiki page with details on how to implement

jongpie avatar Aug 25 '22 20:08 jongpie

Thank you @jongpie and @fentes. I imagined that it is different transactions and what I did was simply use the Save Option on the Save Log Entry element.

I didn't see your response @jongpie, but it seems it's not a bug at all.

presottoAugusto avatar Aug 25 '22 21:08 presottoAugusto

No worries @presottoAugusto! I think at the very least, this would still be good to document in the wiki - I'll work on adding some details about how to setup logging with a screen flow with multiple screens.

If you need anything else, just let me know!

jongpie avatar Aug 25 '22 21:08 jongpie