I have a flow pop open inside a custom modal within an Aura component. Modal popup has an option for user to "X" out of it (close it). Problem is, within the flow, user has ability to upload Files and when user closes the modal, files are still associated with the record. Is there a way to delete files on modal close? Something similar to this maybe?

handleCancel : function(component, event, helper) {
    //closes the modal popiver
    var outputVariables = event.getParam("outputVariables");
    component.set( "v.showModal", false );

Unfortunately, there are no "outputVariables" available on modal close. Is there any other way to retrieve file attached as part of the flow before user decided to move away? I don't think I can use flow status either since the flow itself doesn't fire any event


The lightning file upload component immediately saves the file and attaches it to both the record and the user.

The ways flows work, it wouldn't really be possible to upload only at a certain point in the flow, like a record save event. The file data has to go somewhere.

Now, since this is in a lightning component, you can look at the modal close event, and observe the status of the flow at that time (you can set flow status variables, and catch a status change event onstatuschange). If the flow didn't get far enough and the modal was closed, just call an apex action to delete the file.

You'd just need to add some assignments along your flow to update the status to reflect the progress, so you can know if/when you need to delete on close. enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.