1

I've done my best to summarize my question in the title, but it needs more detail to be understood, here I go:

I have a screen flow where, after a certain number of screens, there is an auto-launched subflow. Until now, the subflow ran, after that there was an assignment and a final screen:

Screen Flow section screenshot

enter image description here

However, this subflow launches a job in an external application, and this job may not be over when the subflow finishes (as it has successfully launched the job) and the final screen (Step 3: View Results) is shown. I'm interested in showing the "Step 3: View Results" screen only when the actual job in the external application has finished.

In order for the subflow to not end until the job in the external application has finished, I went into the subflow and added a "Pause" element. The Apex action launches the job in the external application, and then the "pause" element is waiting for a platform event (that the external application sends to Salesforce once the job has finished), so that the flow only ends when the job has finished:

Subflow section screenshot

enter image description here

So I was expecting the screen flow to show a "loading" symbol until the subflow had finished (therefore always having the job in the external application finishing first), and then showing the final screen "Step 3: View Results". However, I get the following screen:

enter image description here

Which is referring to the subflow, that is paused because it is waiting for the platform event that indicates that the job is complete in the external application. When the flow receives the platform event and continues, it does not show the third screen, it just stays here.

What options do I have in order to avoid this message? My idea was to have a a loading symbol while the subflow was running, and once finished (with the job finished in the external application as well), show the third screen. Instead of using the "wait" element, can I use a loop in the subflow that constantly checks if a record has changed to a certain value (which would also indicate that the job in the external application has finished) and stay in that loop until, for example, a certain record has changed to "Job Complete", and then continue with the flow?

Thanks very much for your help! Let me know if there's anything that is not clear.

Roberto

2 Answers 2

2

Try to add a lighting component that will show the loading screen and also can check if the job is completed and display the result in the same component.

1

Probably I'm wrong, but what I understand is that once a Flow is paused, the automatic resume in the background can take 10-15 minutes (not immediately after the event raises), and then your screen flow will show that message during that time. But I never check it.

A lightning component (Wait Screen component) can be used to avoid the Pause element status message.

And you have to have a mechanism to check the background process is finished OK.

Here is the code I'm using:

<aura:component implements="lightning:availableForFlowScreens">
    <aura:attribute name="seconds" type="integer" default="8"/>
    <aura:attribute name="message" type="string" default="Wait 8 seconds"/>
    <aura:attribute name="secondary_message" type="string" default="Do not click Next or Previous"/>
    <aura:handler name="init" value="{!this}" action="{!c.onInit}" />
    
    <div class="slds-m-around_xx-large" width="100%">
        <p style="white-space: nowrap; display: flex; align-items: center; justify-content: center; margin: auto;">
            {!v.message}
        </p>
        <p style="white-space: nowrap; display: flex; align-items: center; justify-content: center; margin: auto;">
            {!v.secondary_message}
        </p>
        <lightning:spinner alternativeText="Wait" size="medium" variant="brand"/>
    </div>
</aura:component>

I leave it to you to create the Design input attributes.

And the controller where the magic is:

({
    onInit : function(component, event, helper) 
    {
        var seconds = component.get("v.seconds");
        window.setTimeout(
            $A.getCallback(function() 
                           {
                               var navigate = component.get("v.navigateFlow");
                               navigate('NEXT');
                           }), 8000
        );
    }
})

This will show a screen element with a Wait spinner.

Wait screen component

And you have to ensure in your screen flow that you follow these steps:

  1. Execute the background operation.
  2. Create a Screen element with the Wait component only.
  3. Validate whether the background operation is finished or returned.
  4. If not OK, go back to 2.

Check this blog article for more.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .