The total hours are rolled up to the Project object by default in the TimeTracker application.


For any other custom object, you can write a trigger and roll up Approved or Total hours by following the instructions below


Firstly, we need to create the Custom Fields, Custom Trigger, and the related test class with at least 75% code coverage in the Sandbox. Then test the trigger in Sandbox, and push the trigger to the Production org. Because Salesforce does not allow you to write triggers directly in your Production org.


  • Set up triggers in a sandbox to do the roll-ups
  • Write test classes to get code coverage for the triggers
  • Test out the triggers to make sure that the roll-ups in the sandbox
  • Push the triggers to your production org.


Note: As an example, I am using Project as a custom object in this article


In Sandbox Org, 

  • New Custom Field on Custom Object(Project Object): 
    • Create two Custom Fields of Data type number in the Custom Object(Project Object). 
      • Approved Hours (Sum of Hours roll-up from the TT Details object where Status is Approved).
      • Actual Hours (Sum of Hours roll-up from the TT Details object of all statuses).
  • Create a Custom Trigger on TT Details Object:
    • The Trigger will be initiated "After" the Record is (Update/Create/Delete).
    • Logic on Rollup hours:
      • Get all the TT Details from the TT Details Object grouped by Project and Status.
      • Calculating the Hours for both Approved Hours and Actual Hours
        • Summarize the hours for all the statuses.
        • Summarize the hours where Status is equal to Approved.
      • Update the Calculated hours(Approved Hours and Actual Hours) on the Project object.
  • Create a Test Class for the above trigger, and it should cover at least 75% of Code Coverage.
  • Create Inbound Change Set Package:
    • Inbound Change Set should contain, 
      • New Custom Field
      • New Custom Trigger
      • Test Class

In Production Org,

  • From Outbound Change Set
    • Select the Package, 
      • Click on the Validate Button and Check for the Validation Status.
      • Click on the Deploy Button will revalidate all the test scenarios and then deploys the Change Set.