I have two objects A & B, where the relationship is 1:Nobject B has a formula field that calculates hours worked based on a start and end time.In object A I want to create a formula field that calculates the sum of the 'Hours_worked' field of object B.This doesn't seem to work though when using: #CALC_SUM.R32206( Hours_worked )Is there another way to get this sorted?
You can't get the sum of a calculated field. I've solved some sort of problem in the following way:
Create a trigger on object A which calculates the field based on the related records.
var numberOfRatings = #CALC_COUNT.R820158(Rating_Number);
var sumRatings = #CALC_SUM.R820158(Rating_Number);
return numberOfRatings / sumRatings;
And place a trigger on object B which runs the trigger on object A at update/edit/delete
Do I understand correctly that the field in object B cannot be a calculated field in this scenario?
So I have my calculated field in object B (hours_worked) and I first have to get that value into a normal field (by using a trigger to update the field value) in object B?
After that I should be able to calculate the sum of the 'normal field' of object B in my formula field in object A right?
Calculated fields aren't stored in the Rollbase db. They are more used for displaying on object level, they also can't be used for sorting in views. I've also once tried your approach with expression fields (because these are stored in the database) but those fields are only updated when the record is updated. So that's why I've used the approach as described as above.