Call check reference user define function before calling cancel function

How to call user define function to check reference records exists before calling default cancel function and showing the below dialog box. ?

Over ride default cancel function.

I think you need do it with this hooks

override_doctype_class = {
	"ToDo": "custom_app.overrides.CustomToDo"
}

Then in your CustomToDo class

from .... import ToDo

class CustomTodo(ToDo):
  def on_cancel(self):
    # do something
    super().on_cancel()
1 Like

Do you want to show the list of all reference documents linked with the current record?

Yes, that we can query and get the details. The issue now system cancelling the record, by showing the dialog box.

Yes, this is the default behavior of Frappe. If you don’t want to show the popup, then add a custom button on the form and, on button click, cancel this and all related records.