Web form client js script for sending sms and whatsapp messages for erpnext v12

For any non programmers out there finding issue in figuring out to work with javascript on the webform to send messages, you can reference below

ps: you will have to create a field to input mobile no(mobile_no)

//SCRIPT TO SEND WHATSAPP VIA RAPIWHA.COM

frappe.web_form.after_save = () => {
var settings = {
    "async": true,
    "crossDomain": true,
    "url": "https://panel.rapiwha.com/send_message.php?apikey=UPDATE-APIKEY&number=" + "91" + [frappe.web_form.get_values().mobile_no] + "&text=YOUR MESSAGE"
    "method": "GET",
    "headers": {}
}
$.ajax(settings).done(function(response) {
    console.log(response);
});
msgprint('Whatsapp message sent to ' + [frappe.web_form.get_values().mobile_no]);
}




//SCRIPT TO SEND SMS VIA TEXTLOCAL.COM GATEWAY USING INBUILT FRAPPE CALL METHOD

frappe.web_form.after_save = () => {
//function call to invoke send sms
frappe.call({
    method: "frappe.core.doctype.sms_settings.sms_settings.send_sms",
    args: {
        receiver_list: [frappe.web_form.get_values().mobile_no],
        // update sms content within quotes "  "
        msg: "your message"
    },
})
return
msgprint('SMS sent to ' + [frappe.web_form.get_values().mobile_no]);
}
1 Like

@kid is the same useful in V13?

yea, i still use it

1 Like