expand and collapse baised upon a checkbox

essentially I’m trying to get a checkbox to expand a group, depending on its status, that is trigged from a datasheet, not the user. The checkbox is linked to a boolean data type in the sheet and is checking on and off properly I just can’t make it trigger the expand or collapse of the group… and it doesn’t want to work. This is the closest that I’ve been able to get to not knowing much about code.

let isChecked = $w( “#checkbox1” ).checked; // true

if ( $w( “#checkbox1” ).checked === true ) {
$w( “#group1” ).expand();
}
else {
$w( “#group1” ).collapse();
}

});

Turns out its best to look at the datasheet from the start!

w.onReady(()=>{
let Checkedscenery = $w( “#dynamicDataset” ).getCurrentItem();

if (Checkedscenery.Booleanrefferance=== true ){
$w( “#group1” ).expand();
}
else {
$w( “#group1” ).collapse();
}
});