ERPNext Conference 2019* ERPNext.com Blog

SMS Alert: Doing it by Js and python

customization

#1

Does anyone know how to send SMS alert from script ?? i couldn’t find any custom script…

this is the link, it just tells that what will be the settings but i have to do it by script and on_submit button … anyone could help me please… highly thankful


#2

First you need to set SMS Settings and then

  frappe.ui.form.on("Sales Invoice", "on_submit", function(frm, cdt, cdn) {
            var message = 'XYXYXYXYXYX(Your MSG)';


           frappe.call({
                   method: "frappe.core.doctype.sms_settings.sms_settings.send_sms",
                   args: {
                       receiver_list: [frm.doc.contact_number],
                       msg: message,
                   },
                   callback: function(r) {


                       if (r.exc) {
                           msgprint(r.exc);
                           return;
                       }
                   }
                 });
})

#3

i have seen many sms providers and they are providig sample code to integrate it with php, C# and many others but i havent seen i seen simple sample with erpnext… can you please help me with the steps how to integrate and send sms …
thanx in advance @Sagar_Bhogayata


#4

i have to do sms settings here:
http://dev.tektician.com:32006/desk#Form/SMS%20Settings/SMS%20Settings
and then i will get this settings through this above code ?


#5

@Sagar_Bhogayata - thanks - was looking for a way to setup an automatic sms notification. Can you add document number (sales invoice number) or total amount for this custom script? Will appreciate guidance on how to code it…


#6

i am having an issue … when i trigger this event it says the message has been sent to the number but i am not receiving the message on my cellphone… i am using sms provider
https://www.isms.com.my/isms_send.php
i have given its credentials but i think its not making connection with the api … can you help us with that ?


#7

I think you didn’t set SMS Settings Properly… @Owais_Zafar


#8

You need to customized message like

  frappe.ui.form.on("Sales Invoice", "on_submit", function(frm, cdt, cdn) {
        var message = 'Invoice Number is ' + frm.doc.name;


       frappe.call({
               method: "frappe.core.doctype.sms_settings.sms_settings.send_sms",
               args: {
                   receiver_list: [frm.doc.contact_number],
                   msg: message,
               },
               callback: function(r) {


                   if (r.exc) {
                       msgprint(r.exc);
                       return;
                   }
               }
             });
})

How to customise SMS notifications?
How to add SMS dialog in a custom app doctype
#9

Can i write receiver_list like this ??
receiver_list: {
‘doctype’: ‘Property Sales Customer’,
‘filters’: {‘primary_correspondence’: 1,‘parent’:frm.doc.name},
‘fieldname’: [‘customer_tel’]
}, @Sagar_Bhogayata


#10

Now my messages are sent to api and they are showing status that messages has been sent to these numbers but i am not receiving on my cellphones


#11

@Owais_Zafar I think Something went wrong in SMS Configuration, Please check Delivery History from SMS Provider Panel


#13

@zerodiscount There are some Points, In my system works perfectly

  • Check contact number field (in my case frm.doc.contact_number which is the custom field)
  • Check on_submit event triggering or not
  • You can remove callback if you want
  • Check Console log (If any log Please share here)

#14

erpnext sms_manager code url for reference


#15

How do I get the default contact number associated with the Sales Order?


#16

You need to create contact details from the customer which store in contact doctype

and then its fetch to sales order


#17

After some trial and error - this is what seems to work for me:

frappe.ui.form.on("Sales Order", "on_submit", function(frm){
		frappe.call({
               	method: "frappe.core.doctype.sms_settings.sms_settings.send_sms",
               	args: {
                   receiver_list: [frm.doc.contact_mobile],
                   msg: "Your Order "+[frm.doc.name]+" for the amount $"+[frm.doc.grand_total]+" has been received",
               	},
         })
});

SMS Notification Doctype
V12 Notifications via SMS?
#18

Thanyou so much all of you guys , its solved now :slight_smile:


#19

Hi Sagar - with update to V12 - where the mobile_number has been dropped for contact - how are you working with SMS function? Do you continue to use a custom field (which is not affected by upgrade)?