Hi all. I have a user submission form that works fine but I want to be able to have the submission go to an archive collection as well when the user clicks the submit button. I’ve had it working in preview but it doesn’t seem to work on my live site. Here’s the code I used, just basically added the second wixData.save line, any ideas?
$w.onReady( function () {
$w(“#button2”).onClick((event) => { let selectedTime = $w(“#dropdown2”).value.split(“:”);
selectedTime[0] = Number(selectedTime[0]) * 3600000;//converts hours to milliseconds
selectedTime[1] = Number(selectedTime[1]) * 60000;//converts minutes to ms let finalTime = new Date( new Date().getTime() + selectedTime[0] + selectedTime[1]);
Not sure if this’ll help but maybe try having two separate “let toSave” functions and basically copy/paste the values to save. If that doesn’t work then try having two “onClick” events (one for the regular one, other for archive).
wixData.save("Timedout", toSave),
wixData.save("archive", toSave)
.then(() => {
wixLocation.to("/all"); //<<<<< PUT IT HERE
})
Use the Promise.All(). And of course, add the wixLocation.to() to the .then() part.
The Promise.all will make sure it won’t leave the page until both save() actions are successfully done.