Hooks not being called

Becker:

Tomer go me to replace: import wixUsers from ‘wix-users’ w/ import wixUsers from ‘wix-users-backend’ and everything magically worked!

I even got console messages back.

Hi Brett,

I took it out completely, and it still doesn’t work. Glad yours is working. :slight_smile:

Becker, your hook is for before “insert”, but your test hooks page is updating an existing record.
If you add a “beforeUpdate” hook, it will work. “beforeInsert” is used when adding new records to the collection.

Doh! I was rushing… missed that detail.

so this works:

export function TestingHooksCollection_beforeUpdate(item, context) {

item.hookedField = item.editField; 

return item;

}

And this works with a non-existent function and no semi-colon on the include, even though the code editor does not flag either error:

import wixData244 from ‘wix-data’
export function TestingHooksCollection_beforeUpdate(item, context) {
item.hookedField = item.editField;
return item;
}

But this just does nothing, despite not calling anything in wixUsers:

import wixUsers from ‘wix-users’;
export function TestingHooksCollection_beforeUpdate(item, context) {
item.hookedField = item.editField;
return item;
}

How would I go about debugging a problem like this?

And since we discussed this earlier, I can get to the owner this way, so I can get some of the information I need without importing wix-users:

export function TestingHooksCollection_beforeUpdate(item, context) {

item.hookedField = item._owner; 

return item;

}

Like I said before “wix-users” is for client code. You should use “wix-users-backend”. You can read the API docs to understand the difference.

Please understand, this set me back two months. I spent several days looking for an answer and trying different things before posting my question here. With no answer, I had to develop workarounds, workarounds that now need to be cleaned out so maintainnace will be easier. There are no compiler errors providing hints, no runtime error messages providing hints.

Becker, I fully understand and I’m sorry for the delay this has caused. Like I told Brett in his post, we can definitely do better in that area and I will pass it on. We work hard on multiple exciting features, and I hope making the debugging experience better in this area will enter our plans.
Please let me know if I can be of any further assistance to you.