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

Can you share a screen shot of this List.



Thank you,
Ashutosh


Lakshmaiah Dump
Giga Expert

Hi Ram,



It's simple. Go and check the System Definition -> Relationships record and condition, Then use the service side script.



System Definition -> Relationships


Check condition like


current.addQuery('caller_id', parent.caller_id);



User the GlideAggregate object to get the count



var count =new GlideAggregate('incident');
count
.addAggregate('COUNT');
count
.query();var incidents =0;if(count.next())
  incidents
= count.getAggregate('COUNT');




Hit Correct/ Endorsers/ Helpful/ Like depending on the impact of the response


@Lakshmaiah Dumpala


Hi Lakshmaiah,



I couldn't find the relationship which i require in the "System Definition -> Relationships" Table.



What might be the next workaround?



Thanks & Regards,


Ram Prakash


Hi Ram,



Still we have option way we check the condition the related list table.



Open related list -> Go filter icon -> Right click on filtered   record condition -> Using Copy query : You will get the condition


                                                                                                                                                                                                                                            -> Using Copy URL : You will get the both table name and query condition to table.



Ex:-



Copy URL :: https://yourinstance-now.com/clm_m2m_contract_asset_list.do?sysparm_query=contract%3D83be799c9770300000f8d7b8fa297500%5E


Copy query (Condition) :: contract=83be799c9770300000f8d7b8fa297500



For more detailed visualization to you check attached screen.


Get_Table_Condition.PNG



Hit Correct/ Endorsers/ Helpful/ Like depending on the impact of the response


Lakshmaiah Dumpala


Hi Ram,



Still if you have issues keep posting the question in community.



Thanks,


Lakshmaiah Dumpala