Hey I’m trying to update/add two new values to an item in a dynamic dataset when this one is submitted by a user.
Below is the code, d oes anyone know why it is not working? It seems to be working in the editor but for some reason it does not work in the live site
$w.onReady(function () {
$w("#dataset1").onAfterSave(() => {
wixData.aggregate("Alquileres")
.run()
.then((results) => {
if (results.items.length > 0) {
let items = results.items;
let ur = "https://veganflat.com/alquileres/"
let icon =
"https://static.wixstatic.com/media/5b7658_2cb213baa50f4d0382725c74aae58840~mv2.png"
let iterator = items.values()
for (let item of iterator) {
console.log(item)
let ref = item['title']
let id = item._id
let nref = ref.replace(/ /g, "-")
let nurl = ur.concat(nref)
console.log(nurl)
wixData.get("Alquileres", id)
item.icon = icon;
item.maplocations = nurl;
wixData.update("Alquileres", item);
}
}
})
});