0

I have quick action that opens a flow in a modal. I have a lwc component that displays a toast message upon the last screen of the flow. I'm trying to auto close the modal upon reaching the finish screen using CloseActionScreenEvent, but the modal isn't closing when the finish screen is reached.

Here is the code in the js controller:

import { LightningElement, api } from 'lwc';
import { FlowNavigationNextEvent, FlowNavigationFinishEvent } from "lightning/flowSupport";
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { NavigationMixin } from 'lightning/navigation';
import { CloseActionScreenEvent } from 'lightning/actions';
    
export default class flowScreen_displayToastMessage extends NavigationMixin(LightningElement) {
    
    hasRendered = false;
    
    @api recordId;
    @api objectApiName;
    @api title;
    @api variant;
    @api message;
    @api urlLabel;
    @api triggerNavigationNextEvent;
    
    @api
    availableActions = [];
    
    renderedCallback() {
        if (!this.hasRendered) {
            this.hasRendered = true;
            this.showToastMessage();
            this.closeModal();
        }
    }
    
    async showToastMessage() {
    
    // ...<code removed for brevity>...
    
        if (this.triggerNavigationNextEvent) {
            if (this.availableActions.find(action => action === 'NEXT')) {
                const navigateNextEvent = new FlowNavigationNextEvent();
                this.dispatchEvent(navigateNextEvent);
            } else if (this.availableActions.find(action => action === 'FINISH')) {
                const navigateFinishEvent = new FlowNavigationFinishEvent();
                this.dispatchEvent(navigateFinishEvent);
            }
        }
    }

    closeModal() {
        this.dispatchEvent(new CloseActionScreenEvent());
    }
}

I was trying to use the closeModal function and call it after calling the showToastMessage function.

1 Answer 1

2

If I understood your question correctly you are calling the flow directly from a Quick Action.

If you are then all you'd need to do is fire a FlowNavigationFinishEvent.

To my knowledge you'd use CloseActionScreenEvent if you are using an LWC quick action and want to close it

You must log in to answer this question.

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