How to calculate the count from the related list?

kutvaram
Tera Expert

Hi All,

How to get the number present in the related list into a particular string field?

What I mean is "(say) for example, we are having the total count (number) of the related list as '10', that value should be copied to the String field".

Please do let me know how to achieve it.

Any Ideas?

Thanks & Regards,

Ram Prakash

9 REPLIES 9

Ashutosh Munot1
Kilo Patron
Kilo Patron

HI Ram,



Are you taking about records in related list or Number of Related list on the form



Thank you,


Ashutosh


Hi Ashutosh,



Yeah I am saying about the "number of records" in the related list.



Thanks & Regards,


Ram Prakash


Hi Ram,



Excellent!



Then this is easy. Which Related list are you using. I am assuming that it has a parent child relationship



ex:


var count =new GlideAggregate('incident');


count.addQuery('parent',current.sys_id);
count
.addAggregate('COUNT');
count
.query();


var incidents =0;


if(count.next())


{
  incidents
= count.getAggregate('COUNT');


count.string_field_name = incidents.toString();


count.update();


}



Thank you,


Ashutosh Munot



Please Hit Correct, Helpful or like,if you are satisfied with this response.


Hi Ashutosh,



Yeah I am using "User Entitlements" related list which is in the table "Software License".



I checked in "System Definition -> Relationships" but I couldn't locate that.



May I know how to check it? where to check it?



Thanks & Regards,


Ram Prakash