Collapse button when data fiels is empty

Hi everyone,
I read a lot of article before writing to you, tried a lot of codes but I don’t see what I’m doing wrong…
I have a button connected to url on a page, also containing a dropbox created with the great help of a video made by @Code Queen Nayeli connecting to a list of films.
For some field of my dataset, I have no url and the fields are empty, my code didn’t work and I don’t understand why since it works on other page… Could you have a look? I’m on the dark…
Thanks a lot!

Here the code :

import wixLocation from ‘wix-location’ ;
import wixData from ‘wix-data’ ;
$w.onReady(() => {
$w( “#dynamicDatasetCOFFRET” ).onReady( () => {
const item = $w( “#dynamicDatasetCOFFRET” ).getCurrentItem();
if (!item.acheterCeDvd) {
$w( “#buttonAcheterCoffret” ).collapse();
}
});

//Pour le dropdown
$w.onReady( function () {
$w( “#dropdownDVD” ).onChange((event) => {
let title = $w( ‘#dropdownDVD’ ).value;
$w( “#ToFilter” ).onReady(() => {
console.log( “The dataset is ready to be filtered.” );
$w( “#ToFilter” ).setFilter(wixData.filter()
.eq( “titreFilmVideo” , title)
)
.then(() => {
console.log( “To Filter dataset is now filtered with the matching title from the dropdown is ready to be filtered.” );
let linkField = “link-reference-video-titreFilmVideo”
let getItem = $w( “#ToFilter” ).getCurrentItem();
let url = getItem[linkField];
wixLocation.to(url);
})
. catch ((err) => {
console.log(err);
});
});
});
})
})

I’m sorry to bother you again, but I think I have a problem with prioritizing code calls. Someone can help me with this logical way to do? When there’s just one thing, no problem, but when I need to code several things, I sure making big mistake…
Thanks