In Task doctype i need progress should calculate based on no of rows and % of completion

Hi Everyone ,
Task doctype i had two fields one is % progress and other one is percentage_of_completed; percentage_of_completed is in Responsible team table. what i need is in responsible table if i add employee and their completed percentage it should calculate and shown in %progress

formula is
%progress = ((percentage_of_completed) / (totalRows * 100))

eg if i add two employee in table as

  1. Abdul and Percentage as 25%
    2.Mano and Percentage as 35%
    and based on nos of rows it should be added.
    it should calculate ((25+35)/2)*100 and shown in progress

Thanks in Advance

Hi @sathya_raj,

Please try it.

frappe.ui.form.on('Task', {
    validate: function(frm) {
        var totalRows = frm.doc.responsible_team.length;
        var totalPercentage = 0;
        $.each(frm.doc.responsible_team,  function(i,  d) {
            totalPercentage += d.percentage_of_completed;

        var progress = (totalPercentage / totalRows) * 100;
        frm.set_value('progress', progress);

Please set your doctype, child table name, child table field name, and parent fieldname in the script according.

you can also use before_save instead of validate.