You need to add an onAfterSave event handler function to that code so that it all runs after the form has been submitted and saved into your dataset.
https://www.wix.com/corvid/reference/wix-dataset.Dataset.html#onAfterSave
onAfterSave( )
Adds an event handler that runs just after a save.
Description
The onAfterSave() function allows you to optionally perform actions right after a save() operation. When you call save(), the callback is run after the save has successfully completed.
Calling onAfterSave() on a read-only dataset causes an error.
Examples
Register a callback to run after a save
$w("#myDataset").onAfterSave( () => {
console.log("After save");
} );