I need to get sum of values from related list

Rajendra0823
Tera Contributor

Hello All,

 

Can any one help me to get the sum of all value in related list.

My use case is I need to get total worked hours in a record that contains some related list record.

 

Thanks,

Rajendra.

1 REPLY 1

Eswar Chappa
Mega Sage
Mega Sage

Hi @Rajendra0823 You need a display business rule on the demand table for this. And put this code in there

 

 

var total=0;


var grid = new GlideRecord('u_dmn_resources_capital'); //related list table name


  grid.addQuery('u_demand', current.getValue('sys_id'));// update the relationship for related list table


  grid.query();


  while(grid.next()){


total+= grid.u_duration.dateNumericValue();


}


current.u_tot_resource_duration_capital.setDateNumericValue(total);

 

 

 

 

Thanks & Regards,

Eswar Chappa

Mark my answer correct and Helpful if this helps you 😀