Tuesday, 6 February 2018

How to fetch child table content

// territory_action is child table and Customer is parent table , we have fetch weightage  from child doctype and if total is greater tha 100 then only save doctype 


frappe.ui.form.on("Customer", "validate", function(frm, cdt, cdn) {
  var i=0;
var total=0.0;
   var d = cur_frm.doc.territory_action.length;

for (i = 0; i < d; i++) {
total += cur_frm.doc.territory_action[i].weightage;
if(cur_frm.doc.territory_action[i].weightage >=100){
frappe.trow("Please Enter weightage under 100 ");
}

}
if(total >=100)
    {
    total=100;
      frappe.msgprint("Your Weightage total is",total);
}
      else{
       frappe.msgprint( "your total is =",total);
}
});

No comments:

Post a Comment

Django rest api - filter

views.py from django_filters.rest_framework import DjangoFilterBackend class PollList(viewsets.ModelViewSet):     queryset = X.objects...