A question that could also help others as well i think!

Setting boolean value to true after a certain time period! is this possible? :thinking:

Any help is greatly appreciated :pray:t2:

Iโ€™m sorry I didnโ€™t understand the question.

You can use setTimeout function

setTimeout( function (){
$w( โ€˜#checkbox1โ€™ ).checked = true
}, 3000 );

@workiapps Hi ! Thanks for replying! appreciate it. Im afraid it get a little complex!

I have a database that ia have a field of boolean (false) but instead of a checkbox i have a button on click to set that field to true.

what I need is to have max time period that field automatic to true coz sometimes they forget to click the button.

setTimeout(function(){ 
$w('#dataset1').setFieldValue(โ€œfieldkeyโ€œ, true)
$w('#dataset1').save()
 }, 3000);

Learn more on wix-dataset - Velo API Reference - Wix.com

@workiapps thanks again for replying.

maybe ur thoughts on this coz its a little complicated than a simple database but there has got to be a way. thanks

@mycondopal

let toUpdate = {
'_id': itemID,
'inLine': false,
'serving': false,
'served': true,
'queueNo': 0,
'towernameAndUnit': data.tower,
'boolean': false
}

setTimeout(function(){ 
toUpdate.boolean = true
}, 3000)

wixData.update("PMONOWSERVING", toUpdate)

//////////////////////// Another method

let toUpdate = {
'_id': itemID,
'inLine': false,
'serving': false,
'served': true,
'queueNo': 0,
'towernameAndUnit': data.tower
}
wixData.update("PMONOWSERVING", toUpdate)
.then((item))=>{
setTimeout(function(){ 
item.boolean = true
 wixData.update("PMONOWSERVING", item)
}, 3000)
}

/////Hook Method

 export function PMONOWSERVING_beforeUpdate(item, context) {
  item.boolean = true 
  return item;
}
1 Like