[Custom Script] Automatic SMS on Creation of New Document

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!

2 Likes

i think its better to do it in the backend side (python). you can create a task and put it in the hooks.py

@ccfiel
That may be the case, but not everyone(specifically cloud users) has access to the backend. :smile:

1 Like

@ccfiel, Would you be able to show me how to create a sms task via the back end?

@Tanuj may u help/guide me to configure ErpNEXT for AUTO sms ?

@Tanuj did you find any way ?

Can anyone help me to configure sms setting?

https://erpnext.org/docs/user/manual/en/setting-up/sms-setting