function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Laytro80Laytro80 

Rollup with our master - detail

Hi,

 

I have need to roll up data from one object to another but cannot use a master detail relationship.

 

I have an object called project and an object called time sheet.

 

When a timesheet is created and linked to project I want to sum all related time sheet records.

 

I would usually use a master detail relationship but I can't lock timesheet to project as timesheets can be agains most objects.

 

Is there an easy way every time a time sheet is added to project to have a field - total time spent calculate?

 

Thanks

 

Ross

Best Answer chosen by Admin (Salesforce Developers) 
gprafullgprafull

All Answers

gprafullgprafull

Hi Ross,

 

If you dont want to use Master Detail relationship to roll up then Probably you need to write an apex trigger to achieve this functionality.

The trigger should be written on events after insert, after update and after delete.

 

Thanks,

Prafull

laytro1978laytro1978

Thanks for the Prafull,

 

Are there any similar tutorials or examples.

 

Essentially I have an object called project__c and an object called time_sheet__c.

 

I need to sum up time_spent__c on the time_sheet__c object for all time sheets per project.

 

I then need to update time spent every time I insert,update and delete a time_sheet__c.

 

Thanks Ross

 

gprafullgprafull
This was selected as the best answer
Laytro80Laytro80

Thanks I have used this to write my apex triggers.

 

Cheers

 

R