I have security_ value field in child table that security_value i need to calculate that security_value that calculated value will be dispaly in total security registerd field in parent table in child table recently added rows also need to calculate.
This is very urgent plz help me on that every one
NCP
March 16, 2024, 1:18pm
2
Hi @Harika21 ,
Please search in the forum, because lots of this type of post is already there.
Reference:
Hi @msiam ,
Please apply custom/client script.
frappe.ui.form.on('Sales Invoice', {
validate: function(frm) {
ttl_itms_dicnt = 0;
$.each(frm.doc.items, function(i, d) {
ttl_itms_dicnt += flt(d.discount_amount);
});
frm.doc.total_items_discount = ttl_itms_dicnt;
}
});
Please check your field name and set it according.
Then reload and check it.
Thank You!
Hi @Yildirim_Hakan_Savci ,
Please apply it.
frappe.ui.form.on('DocType Name', {
validate: function(frm,cdt,cdn) {
set_total_leave(frm);
}
});
function set_total_leave(frm) {
var doc = locals[frm.doc.doctype][frm.doc.name];
var total_leave = 0;
//Example for table name => $.each(doc.items, function(i, d) {
$.each(doc.Your_Table_Name, function(i, d) {
total_leave += flt(d.annual_leave);
});
frm.set_value("total_leave",total_leave);
}
Set your doctype…
Hi @NinYo ,
Please apply it.
frappe.ui.form.on("Appraisal Template - Performance", {
p_rating: function(frm,cdt,cdn) {
var d = locals[cdt][cdn];
frappe.model.set_value(cdt, cdn, 'p_score1', (d.p_rating + d.p_weight));
}
});
// Syntax
frappe.ui.form.on("Child Table Name", {
field_name_for_trigger_to_value_calculate: function(frm,cdt,cdn) {
var d = locals[cdt][cdn];
frappe.model.set_value(cdt, cdn, 'child_table_total_value', (d.child_table_value1 + d.c…
Add your logic and set it.
Thank You!