How to update a doctype's field when another doctype's value is changed?


I have some issue that if I create a maintenance visit record and then Assign to Me, how can I code to update the status in the record to “Fully completed” if my linked ToDo status is changed to “Closed”?


I think this should be a standard feature!

Since ToDo is in frappe and maintenance is in erpnext, we will have to use hooks.

Add a new function in somewhere in erpnext.utilities for listening on ToDo “on_update” event via hooks.

Then based on its reference_type property, set the property of the document to “Close” using frappe.get_doc.

Also implement for Issue, Task, Opportunity :slight_smile:

And don’t forget to send a PR!

1 Like

Hello Rmehta,

Thanks so much for your reply. I’m quite new to ERPNext, cloud you please explain me in depth or give me some example that how to achieve the thing?
I don’t know much about the hooks and never implemented over it before.
As you mentioned, ToDo is in frappe and Maintenance is in ERPNext.What if modules are in the same application like “Maintenance” and “Task”, how can I code using hooks to create a task automatically after creating a maintenance visit record? And after that if I close the task, how can I define “Fully Completed” to the maintenance record?

Thank you so much in advance.


This guide might be useful for you