Hi I need to push values from frappe.call response into array;
var array=[]
frappe.call({
method:"frappe.client.get_list",
args :{
doctype:'Attendance',
filters:[['attendance_date','>=',values.from_date] ,
['attendance_date','<=',values.to_date]
]},
"callback": function(response) {
console.log(response.message)
for(var i in response.message){
console.log(response.message[i].name)
frappe.call({
method:"frappe.client.get_value",
args :{
doctype:'Attendance',
fieldname :['branch'],
filters:{'name':['=', response.message[i].name]},
},
"callback": function(data) {
// console.log(data)
frappe.call({
method:"frappe.client.get_value",
args :{
doctype:'Medical Crew Salaries',
fieldname :['total'],
filters:{'cost_center':['=',data.message.branch]}
},
"callback": function(r) {
array.puh(r.message.total)
}})})
console.log(array.length) //always return 0
I need to get this array after pushing (r.message.total) outside callback function and the for loop
Thanks in advance