2

I made a flow who simply create a new Cutom Object's record where the user fill a screen component with the information of the future record.

I had a first problem where my flow won't stop after clicking on "Finish" button and so start over again.

I tried making a second Screen who use an aura component who should redirect to the new record.

My component :

<aura:component implements="force:lightningQuickAction, lightning:availableForFlowScreens, lightning:availableForFlowActions">
   <aura:attribute name="recId" type="String" />
</aura:component>

The controller :

({    invoke : function(component, event, helper) {
   // Get the record ID attribute
   var record = component.get("v.recId");
   
   // Get the Lightning event that opens a record in a new tab
   var redirect = $A.get("e.force:navigateToSObject");
   
   // Pass the record ID to the event
   redirect.setParams({
      "recId": record
   });
        
   // Open the record
   redirect.fire();
}})

The design file :

<design:component>
   <design:attribute name="recId" label="Record ID" />
</design:component>

In my flow I retrieve the new record's Id and use it in my last screen :

screend flow that should redirect

Even with that my flow wont end and start over without redirecting to the newly created record. This flow is use in a ListView ButtonList using my Flow's URL. So this is not a Quick Action or a Custom Button, strangely ListView doesn't find Quick Actions using a Flow.

1 Answer 1

1

This is from help doc:-

Local actions that fire force or lightning events might not work properly when you run the flow from:

  1. Flow Builder
  2. Flow detail pages or list views
  3. Web tabs
  4. Custom buttons and links

Instead, test and distribute the flow with a Lightning page, Experience Builder page, flow action, or utility bar. Your developer can also add the appropriate event handlers directly to the component.

As a workaround, you need to add an value Init event. This event is fired when when an app or component is initialized, prior to rendering. Handle this event using the aura:handler tag.

Your component looks like:-

<aura:component implements="force:lightningQuickAction, lightning:availableForFlowScreens, lightning:availableForFlowActions">
   <aura:attribute name="recId" type="String" />
   <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
</aura:component>

and your controller will look this:-

({    
   doInit : function(component, event, helper) {
   
   // Get the record ID attribute
   var record = component.get("v.recId");
   
   // Get the Lightning event that opens a record in a new tab
   var redirect = $A.get("e.force:navigateToSObject");
   
   // Pass the record ID to the event
   redirect.setParams({
      "recId": record
   });
        
   // Open the record
   redirect.fire();
}}

The init event will fire the event irrespective of where you are invoking the flow from.

1
  • The flow doesn't work but now I got the problem. I will create a record from an Aura Component it will be easier
    – Jack
    Commented Oct 18, 2021 at 9:03

You must log in to answer this question.

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