I need to get sum of values from related list
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 03:22 AM
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 04:32 AM - edited 09-01-2023 04:34 AM
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 😀