Data hooks not working with "submit" action

I have a page that collects a few details into a collection. I want to set some session variables based on the data that was collected, so I decided to use the afterInsert hook on the collection. Whether I use custom javascript code for the “Submit” button or use a dataset and connect the submit button to it, either way the afterInsert hook is not getting invoked. Any ideas why?

Hi,
Because the afterInsert hook is called after the insert() is executed, it cannot affect the item that is inserted into the collection. It can only affect the item returned by insert() .
If you wish to update information after the record was already inserted to the database, you would need to call the update( ) function in the afterInsert data hook .

Good luck,
Tal.

Hi Tal,
I tried using beforeInsert, still it did not work. Is there any reason?

Hi,
This is an old post. Please post your question in a new thread and clarify what is the use case and what you would like to achieve. Note that on my previous reply, I haven’t mentioned the beforeInsert function… I recommend re-reading the answer above which may help.

Best,
Tal.