Multiple events from one button timing

Hello, I'm looking for advice on what I believe is a timing issue on a form button. My form has data and a file upload, each of which use separate events to upload the file and send the form data (both to external api endpoints). The form data references the filename for later id in the backend, but sometimes the form data has 1234.pdf (correct) and sometimes it has 1234.2. The file uploaded ultimately has the correct filename and extension. Is there a way I can do uploadfile.trigger() and wait for it to complete before doing sendFormData.trigger()?

Thanks for any help.

Hi @mikev,

You can. You can use the on-success event of the uploadfile resource and then set it to run sendformData.

Here's where you can find it:

Ah perfect! I'm not sure why I totally skipped over that. Thanks @Steven_W!

Np.

You can also do this in a run script section on the click or submit event:

await uploadfile.trigger()
await sendFormData.trigger()

and I think this might work as well but I haven't tested it:

uploadfile.trigger().sendFormData.trigger()

maybe someone could confirm it :sweat_smile:

2 Likes