You need to sign in to do that
Don't have an account?
Jon Foy
Need Help with Apex Trigger Code
We have two custom objects: Task_Custom__c and Timeslip__c.
Timeslip contains these fields:
"Total_Billable_Time__c" (hours)
"Related_Task__c" (a lookup on the Task_Custom__c object)
Therefore when viewing a Task, it gives a list of all related Timeslip's.
What I want to do is have a field on the Task_Custom__c object "Billable_Time__c" which would be a summary of all "Total_Billable_Time__c" from all related Timeslips. I can't do a rollup summary because it's a cross object reference. Is there a way to write an apex trigger for the TimeSlip object that would update the "Billable_Time__c" field on a Task anytime a timeslip is created or updated that is related to that Task?
Timeslip contains these fields:
"Total_Billable_Time__c" (hours)
"Related_Task__c" (a lookup on the Task_Custom__c object)
Therefore when viewing a Task, it gives a list of all related Timeslip's.
What I want to do is have a field on the Task_Custom__c object "Billable_Time__c" which would be a summary of all "Total_Billable_Time__c" from all related Timeslips. I can't do a rollup summary because it's a cross object reference. Is there a way to write an apex trigger for the TimeSlip object that would update the "Billable_Time__c" field on a Task anytime a timeslip is created or updated that is related to that Task?
There is, but I find this point and click package easier and more scaleable
https://developer.salesforce.com/page/Declarative_Rollup_Summary_Tool_for_Force.com_Lookup_Relationships