Dynamic newsletter content - libracore/erpnextswiss GitHub Wiki
The standard newsletter tool from ERPNext so far does not support personalisation of the content (refer to https://github.com/frappe/frappe/issues/6654).
ERPNextSwiss contains a function for this. Simply include the following custom script:
frappe.ui.form.on("Newsletter", {
refresh: function(frm) {
if ((!frm.doc.__islocal) && (frm.doc.email_sent == 0)) {
frm.add_custom_button(__("Send dynamic"), function() {
send_dynamic(frm);
});
}
}
});
function send_dynamic(frm) {
frappe.call({
method: 'erpnextswiss.erpnextswiss.dynamic_newsletter.enqueue_send_dynamic_newsletter',
args: {
newsletter: frm.doc.name
},
callback: function(r) {
frappe.msgprint(
__("The newsletter has been added to the sending queue. It will be sent in the next few minutes."),
__("Newsletter sending") );
}
});
}
With the above script, there is a "Dynamic send" button available. Pressing this will send the newsletter through a function that will enrich personalised content from the respective contact record.
- make sure that all enlisted recipients also have a contact record (otherwise they will be skipped)
Make sure to exactly match tag (including whitespaces).
Tag | Content |
---|---|
{{ first_name }} | contact.first_name |
{{ last_name }} | contact.last_name |
{{ salutation }} | contact.salutation |
{{ letter_salutation }} | contact.letter_salutation |
{{ department }} | contact.department |
{{ designation }} | contact.designation |
Sample message
<h1>Hello {{ first_name }} {{ last_name }}!</h1>
<p>This is a newsletter</p>