Capturing Records' Activity Counts Using Calculated Fields

Hi There,

I have followed the below knowledge base article to rollup related calls,meetings,tasks activity which works brilliantly retrospectively but not when you create new records. When a new lead, account or whatever the module that has the field with the calculation in it is created it shows as NaN (as the record is new there will obviously be no activity related to it) and stops you from saving the record in the 1st instance.

https://support.sugarcrm.com/Knowledge_Base/Administration/Studio_and_Module_Builder/Sugar_Logic/Capturing_Records_Activities_Counts_Using_Calculated_Fields/

I really like this count, how can I work around it to avoid this error?

I am using on demand 7.6

Thanks in advance for your assistance,

SV

  • Have resolved the issue by adding an ifElse element to it to deal with the NaN:

    ifElse(equal(add(

    rollupSum($calls,"activity_count_c"),

    rollupSum($meetings,"activity_count_c"),

    rollupSum($tasks,"activity_count_c"),

    count($notes)),"NaN"),0,add(

    rollupSum($calls,"activity_count_c"),

    rollupSum($meetings,"activity_count_c"),

    rollupSum($tasks,"activity_count_c"),

    count($notes)))