Execute code "on remove" of doctype

I have a link from my erpnext doctype to the google calender api. When I update or create my doctype “Concert” the google api creates or patches an event in my google calender. This is working.

When I delete the concert from list view. How can I listen for this action to perform the action “cancel event in google calender”?

hook on_trash method.


Thank you. I searched for all possible terms for this issue but not “trash” =)

It just happens nothing. The concert is removed without a trace but the function is not invoced.

frappe.ui.form.on("Concert", "on_trash", function(frm) {
    alert("cancel event");

Hi @Alexander_Haase,

Please check on_trash hook in frappe here

add the similer event in your apps hooks.py and write a method in your doctype file.
for example

"Concert": {
	"on_trash": "yourapp.yourapp.concert.methodname"

and in concert.py you can write your code

def methodname(doc, methood):
	# your code

Thanks, Makarand

1 Like

thank you, that makes sense. And what can I do for executing my javscript code for update the google calender? I cannot do this in python so there must be a reference?


I have an issue with this on_trash event call.
Everything is working well when the item deleted but it also executes when the item is not deleted due to some other dependency. So is there any other way that executed only after the item deleted?