I was looking for a way to send an SMS automatically to customers once the Sales Order was created a few months back, but couldn’t find any way to do it.
Today, I was looking at this again, and I figure out the following Custom Script for anyone else looking for the same feature:
frappe.ui.form.on('Sales Order', 'after_insert', function(frm){
var message = '[Test] Order No: ' + frm.doc.name + ' has been accepted against ' + (frm.doc.po_no ? ('your PO No: ' + frm.doc.po_no + ' and ') : '');
console.log(message);
frappe.call({
method: "erpnext.setup.doctype.sms_settings.sms_settings.send_sms",
args: {
receiver_list: [frm.doc.contact_mobile],
msg: message,
},
callback: function(r) {
if(r.exc) {msgprint(r.exc); return;}
}
});
})
Cheers!