Set default email template for doctype

Is there a way to set the default Email Template for a DocType?

In Print Format i can say “This is the default print format for DocType Quotation”. I need the same for Email Templates.

Thanks!

Hi rmeyer,

I did it, but not linked to doctype. I linked it to print format.

I add a custom field to print_format. A link to email_template.

Then I add this .js in public folder of my custom app.

frappe.views.CustomCommunicationComposer = frappe.views.CommunicationComposer.extend({
	prepare: function() {
		this.setup_subject_and_recipients();
		this.setup_print_language();
		this.setup_print();
		this.setup_attach();
		this.setup_email();
		this.setup_last_edited_communication();
		this.setup_email_template();
		
		// this line add email template to email dialog.		
		this.dialog.fields_dict["email_template"].set_value(frappe.model.get_value("Print Format", this.dialog.fields_dict.select_print_format.get_value(), "email_template"));

		this.dialog.fields_dict.recipients.set_value(this.recipients || '');
		this.dialog.fields_dict.cc.set_value(this.cc || '');
		this.dialog.fields_dict.bcc.set_value(this.bcc || '');

		if(this.dialog.fields_dict.sender) {
			this.dialog.fields_dict.sender.set_value(this.sender || '');
		}
		this.dialog.fields_dict.subject.set_value(this.subject || '');

		this.setup_earlier_reply();	
	},
});

frappe.views.CommunicationComposer = frappe.views.CustomCommunicationComposer

Don’t forget to add your .js file in build.json.

1 Like

Thanks!

Is this still the way to go?

I never actually used this but we could surely implement it (and contribute it back to frappe).

1 Like

I think this would a realy useful core feature, when one would be able to set a default email template for a doctype…but its sounds more like a job for you, then me :slight_smile: let me know if you have any intentions, i would consider a small bounty for a feature like this.

Thanks @itsdave, I would be happy to build this!

Is there anybody else willing to support this?

Here’s a first draft. It still needs testing, possibly further development, and docs.

https://github.com/frappe/frappe/pull/12264

4 Likes