Delete immediate past image file

I have a picture uploader and I’m trying to delete the previous (current) image when I upload a new one. If I implement this action when the picture uploader’s value has changed, it will just delete the new image file that I uploaded.

Right now I have a delete button grouped with the picture uploader. That works but I was hoping for a more straightforward setup. Maybe this post is better suited for the ideaboard.

Hi @sydney22,

Maybe when the picture uploader is changed, you can set a temporary state that will delete the anything in that state that is not what the picture uploader is?

Does that make sense?

1 Like

Thanks, @johnny! Would this work?

Set the state to “yes” for the new image in the uploader’s value changed workflow, then add an action to delete the file only when the file’s state is “no”, then after that action set the new image’s state to “no”. That way the next time a file is uploaded, the existing file will be tagged “no” and can be deleted.

Hi @sydney22,

I was thinking more of create a state of list of texts, and whenever the uploader’s value is changed, then add the file url of the uploader to that list of texts, and then when you have you submit button or whatever, you could run a recursive WF referencing the state of texts (which would be the file URLs), and just make sure that it doesn’t equal the current uploader’s value’s url

1 Like

Oh ok, cool. I’m kind of doing that now but instead of a state, I have an actual data type + fields. When the uploader’s value changes, the url is added to that list. The only difference is I’m running the recursive workflow when the user hits a delete button. I’ll try to apply the same concept to your state idea.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.