Please help anyone. Why are none of my Collection hooks working?
export function JobsAvailable_beforeUpdate(item, context) {
// Get Shifts Totals
wixData.query("ShiftsAvailable")
.eq("jobId", item._id)
.find()
.then( results => {
item.shiftsTotal = results.totalCount;
// Get ShiftsTaken
wixData.query("ShiftsTaken")
.eq("jobId", item._id)
.find()
.then( results11 => {
item.shiftsTaken = results11.totalCount;
// Calculate & return
item.shiftsNeeded = item.shiftsTotal - item.shiftsTaken;
return item;
});
});
}
My hooks don't seem to work either and I used examples straight from the forums. BTW: On a beforeUpdate, why would akliewer99 need a promise?
Hey there,
Seems to me like you're not using Promises correctly. Your hook function is not returning anything. Take a look at this article, which should help. Your feedback on the article is greatly appreciated.
https://support.wix.com/en/article/working-with-promises-in-wix-code