Schedule a workflow when user leave the page

Hello everyone…

I have a page where users fill out an application and have to upload some images.

If the user decides to cancel and close the window or for any reason, the application doesn’t go to the database, the images that have been uploaded have to be deleted.

How do I trigger a workflow before the user leaves the page or trigger a workflow when a certain time is passed, to delete those files?

I really appreciate any help you can provide.

The first thing that comes to mind is to schedule a backend workflow as soon as a file has been uploaded.
In this workflow you check if the user actually completed the operation, if not then delete the file.
Figure out a reasonable time for completing the operation and schedule the backend workflow for that time in the future.
For example the user uploads a file and you schedule the check/delete workflow for 5 hours in the future.

Hello, maybe using a custom estate will solve your problem, so everything that was filled out stays there temporarily if it is not sent to the db you delete it.
Hope it can help!

So I have to find out a way to check if the user has completed the application and if not to delete the right files… interesting approach.

The problem is that I don’t know how to check if the user has completed the application.

Thanks, @dorilama

But custom state works for as long the page is not closed. How do I trigger the workflow when the page is closed?


1 Like

the custom state remains on the page or element until the page is reloaded or refreshed, there you can work with unit data or list data, then you create a new item in the table.
thinking about the personalized state, if the user reaches the end he will click on the save or finish button and all the stored data will be sent to the DB, otherwise he will leave the page and the data will be removed, I believe there may be other ways of do that, but that was the first solution I thought of for your case.

I’m talking about uploaded files… how to relate uploaded files with the custom state?

ok, do this and let me know a little more about the flow that the user needs to do on your page so that I can try to find a possible solution.

Well, it’s simple… Users fill in some input fields and then upload some files.

Later user decides not to send the application and closes the window.
The input fields obviously are cleared because are not stored in the Database but the uploaded files remain because are stored in File Manage

Thanks for your answers

This is easily solved. As soon as the user starts to fill the form create a thing in the database to store the data and a reference to the uploaded file. If the user finishes the application add this information as well. At the same time schedule the backend workflow in x time. When it executes you will know if you can delete the file or not and you can always delete the thing in the database at the end if you don’t require it anymore.

Actually I have created some fields in Current User (to use them as custom state), to reference the Uploaded Files. But I don’t know how to create exact Backend Workflow to execute.

Beside that I have created a condition in Page is Loaded that will erase those fields in Current User, so when user start an new “application” the fields are empty.

My idea was that if the user start a new application and the uploaded files from the previews application are still on the File Manager, will be deleted along with the Current User fields.
But as I said, I don’t know how to create appropriate workflow for this.

Thanks again

Hello Fabiano, I created a project to test what you want to do, see if that’s really what you need?
Follow the links below the first is the preview and the second is to see what I did in the project.
Use the debug to check what happens after the checkbox is selected, it saves all the inputs for the temporary fields and if the person clicks on save these data go to the database if not click on close and the inputs are reset and it does refresh the page so the custom states are zeroed again.

I hope it helps!

Are you aware that the file upload will upload the image to the backend anyway?
It doesn’t matter if you use custom state or not.
Your method works only for non-file inputs.

I was talking about creating a different datatype for this purpose

Hi @cantareiramartins

Thank you for the test project.

I saw the preview and the editor. I uploaded the files and after that, I closed the window. I went to the File Manager and the files were still there. Not deleted.
You have implemented the cancel workflow of Upload File (Bubble element).

I have to say that I’m using a plugin for uploading files. Its called Multi Uploader

I can’t use your workflow…

Thanks again for trying.

I have created the fields for this purpose

You’re welcome, but if you can already open your mind to the solution, it’s already worth it!

1 Like

but it’s clearly not fit for the purpose if your user can start the process multiple times.
The process is actually simple, roughly something like:

  • create datatype task
  • create custom state task in the page
  • when the user fill an input, only if custom state task is empty, create task and set the custom state and schedule a cleanup workflow x time in the future with the task as parameter
  • if the user submits the task set a field (let’s call it done) as yes
  • on the cleanup workflow if the task is not done delete the uploaded file, after this operation you can decide to delete the task as well

As a bonus you can actually save all the task data to the database and on page load check if the current user has already an open task. If yes then load it (inputs + custom state) so the user can resume the task. Remember to cancel the cleanup task (you have to save the workflow numer on the task when you schedule it) and schedule a new one.


I think I understand what you are saying. I will give a try and I will come back :sweat_smile:

Thanks, @dorilama

Hi @dorilama

The way you described works, but I have an issue. It deletes all files and all the items on the datatype but leaves one file behind on the file manager. One file won’t be deleted. Maybe I haven’t set the workflow correctly.

This is what I have done

I’m testing it by clicking a button

And the API in the backend


Thanks again