Works great in preview but not in publish mode

I’m accessing two datasets:
$w . onReady ( () => {
$w ( “#plantSaleEntries” ). onReady ( () => {
console . log ( “plantSaleEntries ready” );
});
$w ( “#plantSaleCounts” ). onReady ( () => {
console . log ( “plantSaleCounts ready” );
});
//Set dataset index to 0 - first index in collection
$w ( “#plantSaleCounts” ). setCurrentItemIndex ( 0 ); //Set to first index
$w ( “#errSlotFull” ). hide (); //Hide poss. previous error msg
});

I then access a dropdown to select a time slot then store values on the plantSalesCount dataset:

export function submit_click ( event ) {
console . log ( “Entered submit” );
$w ( “#plantSaleCounts” ). setFieldValue ( countsTime , countsVal );
console . log ( "countsTime, countsVal = " , countsTime , countsVal );
$w ( “#plantSaleCounts” ). save ();

This works perfectly in preview mode but in publish mode values are not updated in the plantSaleCounts database. I hope someone can spot the problem or give me a hint…
Thanks in advance.

Hi, I think it happens bacauze of live database doesn’t have items. Sync sandbox to live then check.

To sync the database:- go to database there you will see an option “sync” choose that and then sync items to live database.