Doc event for webform

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.


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?

You can have a if doc.is_new() condition in on_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.

Probably your doctype is not submittable. You should use after_save() which should just run after the document is saved to database.

Yes you should execute all of this in the doctype based on which you have created the webform.

Yes, it is not submittable.

It is not executed. The code stops after completing def validate(self).
The document is correctly saved.

Do I have to put something in

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.

  • Check the indentations
  • bench migrate
  • bench build
  • bench restart

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?!?)

In this frappe documentation I don’t see after_insert or after_save.

I did see them somewhere in other documentation, but I got lost in the new docs/turorial :smiley:

Well anyway… thanks for your help. I will try this and that… at least there must be something I can learn in the process :slight_smile:

1 Like

Please refer to the this doctype documentation as well. Even though somethings are missing like after_save but they provide more information.

1 Like

OK thanks

Sorry… one other thing.
Do you know which file in frappe that process the saving of webform data into the doctype document?
I can’t find it.