Calculation In ERPNext

I want to calculate all A-grade students in one field and B-grades in another and the same for F-grades in the total failed field how can I do this?

Hi @Syed_Anas,

Please check the reference:

Thank You!

frappe.ui.form.on(‘Price Amount Distribution CT’, {
function calculateTotal(frm) {
var childTableData = frm.doc.prizes || ;
var totalSum = 0;

for (var i = 0; i < childTableData.length; i++) {
    var raw = childTableData[i];
if(raw.grade === 'A'){

frm.set_value('total_student', totalSum); 

// Fixed this line


I have tried this but it doesn’t work is there any error?

Where is the validate event?

Please check the example.

Thank You!

Thank You