I am using Opportunity doctype in Frappe. Whenever I create an event, emails are automatically sent to the associated contact, which is not intended. I specifically want emails to be sent only to the event’s creator.
I’ve identified the function responsible for sending emails, which is located in form_timeline.js:
get_recipient() {
if (this.frm.email_field) {
return this.frm.doc[this.frm.email_field];
} else {
return this.frm.doc.email_id || this.frm.doc.email || “”;
}
}
Could someone please advise on how to override this function or suggest an alternative method to ensure emails are sent only to the event creator? Your assistance is greatly appreciated.
You can do monkey patching in your custom app. In your app’s hook, see the app_include_js list, and add your monkey patching file there. If no file is listed, you can create your own, like patching.bundle.js, in the public/js folder.
The code should look like this:
import FormTimeline from "../frappe/frappe/public/js/frappe/form/footer/form_timeline";
FormTimeline.prototype.get_recipient = function() {
// your code
}
I followed all above mentioned steps and im getting error : GET http://127.0.0.1:8000/hilltop.bundle.js net::ERR_ABORTED 404 (NOT FOUND)Understand this error
jquery.js:3539
I was trying to create override a function from healthcare app which is I need create custom code for update_status method which is originally defined in patient_appointment.js
can I know how can override a function and it is not a class
Yes @Anisha_Jain
This function is in FormTimeline class you can extend this class and overwrite the get_recipient function and the add the overwrite js file through hooks.py