if you are complaining " .then((results) => { …});" not working, you probably need to insert the following before the code:
.then((resolve, rejected)=>{
let count = $w("# dynamicDataset “).getTotalCount();
$w(”# dynamicDataset ").getItems(0, count)
.then((results) => {
resolve (results)
})