How to override JavaScript Function

Hello everyone,

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 || || “”;

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.

Thank you!

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