what I want to do is disable print from student applicant document if student still has outstanding balance. I tried this script but nothing happens.
frappe.ui.form.on("Student Applicant", {
onPrintDocument: function(frm, doc, ev) {
// Get the Fees document
const feesDocument = frappe.get_doc("Fees", frm.doc.fees);
// Check if the outstanding amount is 0
const outstandingAmount = feesDocument.outstanding_amount;
if (outstandingAmount === 0) {
// The outstanding amount is 0, allow printing
} else {
// The outstanding amount is not 0, prevent printing
frappe.msgprint(
"Fees payment not received in full. Cannot print."
);
ev.preventDefault();
}
}
});