Hello,
I am using code to submit data from a from into a collection using the Save function. I am using the example in the Velo Reference ( https://www.wix.com/velo/reference/wix-dataset/dataset/save .
$w(“#myDataset”).save()
.then( (item) => {
let fieldValue = item.fieldName;
} )
.catch( (err) => {
let errMsg = err;
} );
I used the example above and it works perfectly in the Preview mode. But when I publish and test viewing the published site, it creates hundreds of records. Does anybody now why this happens?
Below is the code attached to the Submit button. The code includes a validation.
export function button1_click(event) {
//VALIDATE THE COUPON FIELD
$w( “#input1” ).onCustomValidation( (value, reject) => {
if (value === “THX1138” || value === “” ) {
validationMessage = "" ;
$w( "#dataset1" ).save()
.then( (item) => {
let fieldValue = item.fieldName;
} )
. catch ( (err) => {
let errMsg = err;
} );
setTimeout( function (){wixLocation.to( “/testing-upload-function” )}, 0 )
} else {
validationMessage = “Coupon code not valid” ;
}
reject(validationMessage);
$w( “#wrongCodeMessage” ).text = validationMessage;
} );
}