Average in scripts
When I have a calculation field with code
it actually calculates an average based on the relationship. This record is related another table occurance with multiple records (one to many)
When opening a layout using this field it takes forever, so I want to make this calculation with a script instead. However, when running the script Average(field) returns just the content of the first record. Why?
Does my explination make sense? how can I get the avarage of all related fields inside a script?