Question regarding Custom script

Hello,

I have the following custom script:

frappe.ui.form.on(‘Sesizari’, ‘validate’, function(frm){
var message = “Buna Ziua! Sesizarea Dumneavoastra a fost inregistrata! In maxim 24H urmeaza sa fiti contactati de echipa GEI Service pentru rezolvarea sesizarii! Multumim!”

    console.log(message)
    frappe.call({
       method: "frappe.core.doctype.sms_settings.sms_settings.send_sms",
       args: {
                 receiver_list: [frm.doc.numar_telefon],
                 msg: message
        },
       callback: function(r) {
                 if(r.exc) {
			msgprint(r.exc); 
			return;
		}
       }
   });

})

This Custom Script is sending sms when ,Save" button is clicked.

What can I use instead of ,Insert" to have the SMS sent ONLY when the document is created not anytime when ,Save" button is clicked.

Thanks!

Hi,
frm.doc.__islocal variable is true when the doc is not saved, hope you can use this.

if(frm.doc.__islocal){
//sent sms
}

Thanks

1 Like

Hello @Ranjith where exactlY i need to add this?

I have tried and is not working…:frowning:

any idea?