I have tried to set up sms alert on submission of leave application by employee. I have a good and working settings for sms.
I tried the following code through client script.
Doctype: Leave application
Apply to: Form
Enabled: checked on
Script:
frappe.ui.form.on("Leave Application", "after_save", function(frm) {
var message = 'New Leave Application by ' + [frm.doc.employee_name] + ' FROM ' + frm.doc.from_date + ' TO ' + frm.doc.to_date ;
frappe.call({
method: "frappe.core.doctype.sms_settings.sms_settings.send_sms",
args: {
receiver_list: '980000000', // contact number
msg: message,
},
callback: function(r) {
if (r.exc) {
msgprint(r.exc);
return;
}
}
});
})
I get the following error:
AttributeError: ‘int’ object has no attribute ‘replace’
Also this is the error message:
### App Versions
```
{
"erpnext": "13.18.0",
"frappe": "13.18.0"
}
```
### Route
```
Form/Leave Application/HR-LAP-2022-00010
```
### Trackeback
```
Traceback (most recent call last):
File "apps/frappe/frappe/app.py", line 68, in application
response = frappe.api.handle()
File "apps/frappe/frappe/api.py", line 55, in handle
return frappe.handler.handle()
File "apps/frappe/frappe/handler.py", line 31, in handle
data = execute_cmd(cmd)
File "apps/frappe/frappe/handler.py", line 67, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File "apps/frappe/frappe/__init__.py", line 1208, in call
return fn(*args, **newargs)
File "apps/frappe/frappe/core/doctype/sms_settings/sms_settings.py", line 56, in send_sms
receiver_list = validate_receiver_nos(receiver_list)
File "apps/frappe/frappe/core/doctype/sms_settings/sms_settings.py", line 26, in validate_receiver_nos
d = d.replace(x, '')
AttributeError: 'int' object has no attribute 'replace'
```
### Request Data
```
{
"type": "POST",
"args": {
"receiver_list": "9800000000",
"msg": "New Leave Application by Test Employee Ttt FROM 2022-03-29 TO 2022-03-29"
},
"headers": {},
"error_handlers": {},
"url": "/api/method/frappe.core.doctype.sms_settings.sms_settings.send_sms"
}
```
### Response Data
```
{
"exception": "AttributeError: 'int' object has no attribute 'replace'"
}
```
Also, currently I have tried to hard code the receiver phone number, but I want the sms to go to the assigned leave approver’s num.
Can anyone help me what’s the error in the code.