Issue with File Buttons

I have an app with several forms that include file buttons. When one of these forms is submitted, after the main table is updated, the app fetches the id of the row that was updated and then, if a file has been selected with the file button, inserts that id and the file into a second table.

Previously, in order to avoid inserting a row if there was no file being uploaded, I had the event handler that triggers that insert query set to only run when [buttonName].files.length > 0.

However, I recently upgraded all my file buttons and the files property no longer exists. Having looked at all the documentation for the file button, I thought my best bet was to reference the value property instead; since value only appears as a property if a file has been selected, I set the only run when portion of the even handler to [buttonName].value. Elsewhere in my app, I have used ![buttonName].value to successfully make a query only run when a file has not been selected. Unfortunately, the insert query is running (and throwing an error because the field for the uploaded file cannot be null) even when a file is not selected.

What do I need to reference in the only run when portion of the event handler in order to make sure the query only runs when a file is selected? I'm on self-hosted 3.33.31 and may not be able to update to 3.52.1 for a couple weeks.

Hi @LindenKel Thanks for reaching out!

I'll do some testing and follow up :slightly_smiling_face:

I'm not seeing the same issue with fileButton1.value.length>0 :thinking: Could you share some screenshots?

The .value property should be an empty array when no file has been selected

Thanks for looking into this.

This is what I'm seeing when I look at the state for the file button with nothing selected. Value, which is usually at the top of the list is not there.

Then, once I select a file, I see this. Value is now where I expect it to be.

In my success handler, if there is no file selected, I see this:

As I mentioned, I'm currently working on an out-of-date version of self-hosted Retool and won't have the opportunity to update it for another week at least, so it's entirely possible that this will resolve itself once I update. In the meantime, I've solved my problem of the success handler triggering when there is no file selected by changing Ony Run When to {{accrPDFButton.value !== undefined}}, which seems to be working so far.

I'm glad you have a solution for now!

I am also testing on self-hosted 3.33.31 :thinking: I've only been able to reproduce this issue with old components that I've upgraded with this button:

If I drag and drop a new component, I don't run into this issue. Curious if you're seeing the same behavior? It doesn't look like upgrading the Retool version to 3.52.1 will solve this discrepancy

Yes, they were all old components I upgraded that way. I'll have to swap them out for new components.

1 Like

:disappointed: That's my recommendation, unfortunately. I flagged this to our team as a bug, but I'm not sure that we'll be able to prioritize it in the near future