I am exploring the education domain and I would like to add a new DocType for units per course.
So how can I add the units per course… Can someone explain to me how can i generate a custom scripts for this total… I am referring to this code that add up all the qty of all items…
frappe.ui.form.on("Stock Entry", "refresh", function(frm, cdt, cdn) {
// code for calculate total and set on parent field.
total_qty = 0;
$.each(frm.doc.items || [], function(i, d) {
total_qty += flt(d.qty);
});
frm.set_value("total_qty", total_qty);
});
sir if i made a new doctype for that code… example General Schedule do i have change the code like this
frappe.ui.form.on(“General Schedule”, “refresh”, function(frm, cdt, cdn) {…
sir can you help me with my code its not working at all… i very confuse about it…it seems my loop has the a wrong field name… i cant actual find what wrong on the my code… please do help me…
frappe.ui.form.on("General Schedule", "refresh", function(frm, cdt, cdn) {
// code for calculate total and set on parent field.
total_units= 0;
$.each(frm.doc.items|| [], function(i, d) {
total_units += flt(d.qty);
});
frm.set_value("total_units", total_units);
});
//i also try this code: i change the doc.items in the loop the item to subject and units instead of qty. please help me..
frappe.ui.form.on("General Schedule", "validate", function(frm, cdt, cdn) {
// code for calculate total and set on parent field.
total_units= 0;
$.each(frm.doc.subject|| [], function(i, d) {
total_units += flt(d.units);
});
frm.set_value("total_units", total_units);
});
SyntaxError: Invalid or unexpected token
at Class.setup (http://localhost:8040/assets/js/form.min.js?ver=1522523161.0:2693:18)
at _f.Frm.setup (http://localhost:8040/assets/js/form.min.js?ver=1522523161.0:172:22)
at _f.Frm.refresh (http://localhost:8040/assets/js/form.min.js?ver=1522523161.0:446:9)
at Class.load (http://localhost:8040/assets/js/form.min.js?ver=1522523161.0:87:33)
at http://localhost:8040/assets/js/form.min.js?ver=1522523161.0:82:7
at Object.callback (http://localhost:8040/assets/js/desk.min.js?ver=1522523161.0:5516:6)
at Object.callback [as success_callback] (http://localhost:8040/assets/js/desk.min.js?ver=1522523161.0:1437:16)
at _ (http://localhost:8040/assets/js/desk.min.js?ver=1522523161.0:1461:34)
at Object. (http://localhost:8040/assets/js/desk.min.js?ver=1522523161.0:1562:5)
at i (http://localhost:8040/assets/frappe/js/lib/jquery/jquery.min.js:2:27151)