Sum total value from related list

Andrew_TND
Mega Sage
Mega Sage

Hi, I know I need to create a business rule but struggling on how as I quite new to coding.

I need to show the sum of hours on our time cards in the state of submitted but have this show on our contract table.

Can anyone help me out with script or point me in the right direction it would be greatly appreciated.

Thank you 🙂

4 REPLIES 4

Alikutty A
Tera Sage

Hello,

You could display the sum on the List view using List Calculations. You can right click on your list and configure Sum in the specific column under List calculations.

find_real_file.png

 

find_real_file.png

 

Hi thanks I know this however there a requirement for this to be populated in a field if you know how?

Snehal Pawar
Tera Expert

Hello,

You can refer below link

https://www.youtube.com/watch?v=JQ7dzAnNhqI

 

Thanks,

Snehal.

johansec
Tera Guru

Is this an OOB table?

here is a code example but i can make a better one if i knew the table and the fields. 

Hopefully this will get you started.

var count; 
var gr = new GlideRecord('INSERT TABLE NAME HERE');
// Check the choice list of this field to see what the value of the submitted option is
// It could be a numeric value or string depending on the field
// Assuming the name of the field is state and the desired value is 1
gr.addQuery('state', 1); 
gr.query();
while (gr.next()) {
    // Depending on the field hopefully this is an integer field
    count += parseInt(gr.hours.toString()); 
}

// Here your count is stored now
gs.log('My count: ' + count);