Disable and enable Buttons based on a database entry

Hi dudes,
I have a dynamic page and on that page I want to show a download button. With the download button you can download a file from a dataset (user generated content). So fare there is no problem.

Now my problem: I only want to enable the button when there is content available.

I’m a bit frustrated. Maybe someone can help me. Thanks in advance.

This is my not working code so fare:

$w ( “#dynamicDataset” ). onReady ( () => {

$w ( ‘#lebenslauf’ ). value = $w ( “#dynamicDataset” ). getCurrentItem (). fieldName ;

if ( $w ( ‘#lebenslauf’ ). value === ‘’ ) {
$w ( ‘#button1’ ). disable ();
}
else {
$w ( ‘#button1’ ). enable ();
}
})

FieldName can not be found. But it is in the data collection

Are you sure the field name in the collection is fieldName ?

Thanks for your answer Bruno. No, its Lebenslauf I will try with a change

I tried without success. The field name is correct now