There are many doc events for desk form for client or server side.
But from the documentation I can see only validate and before_insert for the webform.
Is there any other events (most likely the server side) can be used for webform (direct code or via hooks)?
Specifically I’m looking for the equivalent of after_save or after_insert, but the one that saved/inserted by code.
So the scenario is to have a webform for inputting data, the form saved and insert a doc in the doctype, after the doc is saved/inserted trigger a code to run.
Thanks.
EDIT: There is handler on_update : Called after the document is inserted or updated in the database.
My issue above is a handler that only trigger when the doc is new (after inserted only) and not triggered when update?
It doesn’t work.
Maybe because I insert the doc with code?
In order to save the form data into the doctype, I run:
def before_insert(self) then def validate(self)
upon success of validation the data is inserted into the document (doctype).
What I want to achieve is, after the document is inserted (that Saved Successfully popup message on the webform) then my other code should run.
If I put my other code in validate() then it might be too long for the Saved Successfully to appear.
Using after_insert() also doesn’t work. The code in after_insert() is not processed.
Btw, I run these code in server.
hooks is used when you want to hook into already defined doctype methods.But If its your custom doctype then you can directly write the code in your controller. I think probably you need to re-look at your controller code. You are doing something wrong.
I believe my code is fine because when I put it in the validate method it runs well. So my problem is in defining the correct event handler.
I suspect it has to do with webform as the source of data or trigger (the way it process after event perhaps?!?)
save method in frappe-bench/apps/frappe/frappe/public/js/frappe/web_form/web_form.js makes a POST call to frappe.website.doctype.web_form.web_form.accept