I’m trying to debug a couple of custom scripts I wrote for my custom app that were working in v9 but no longer are. The first is as follows:
frappe.ui.form.on("Batch Process", {
onload: function (frm) {
frappe.model.clear_table(cur_frm.doc, "batch_docs");
cur_frm.save();
frappe.call({
"method": "frappe.client.get_list",
"args": {
"doctype": cur_frm.doc.batch_type,
"fields": "bill_no, bill_date, name",
"filters": {
"batch_id": ["=", cur_frm.doc.batch_id],
"status": "Draft"
}
},
"callback": function (res) {
console.log(res)
if (res.message) {
for (i = 0; i < res.message.length; i++) {
var new_row = cur_frm.add_child("batch_docs");
new_row.invoice_number = res.message[i].bill_no;
new_row.document_date = res.message[i].bill_date;
new_row.document_name = res.message[i].name;
cur_frm.refresh_field("batch_docs");
}
}
}
});
}
});
This is supposed to check documents of the specified doctype to see if their batch ID matches that of the current document, and if so populate a child table with various details about the document. As stated, this was working fine in v9 but now it doesn’t seem to do anything.
The second script adds a button that calls a custom function to submit all the documents in the batch:
frappe.ui.form.on("Batch Process", "refresh", function(frm) {
cur_frm.add_custom_button(__("Submit Batch"), function() {
frappe.call ({
"method": "mobile_fun_customisation.controllers.batch_process.submit_documents",
"args": {
"doc": cur_frm.doc
}
});
});
});
This does seem to be working however it duplicates the button on screen. When I remove the frappe.call function and replace it with frappe.msgprint, there is only one button.
Any help resolving either issue would be greatly appreciated.