Hi guys I am a complete n00b with SalesForce.com, so please forgive me if my question is too basic, but I have been trying for about 2 days now and I feel like I am getting nowhere

I have a database that includes two objects: Teacher and Timesheet. The Timesheet object is the many side of a one to many relationship with Teacher.

I would like to be able to count the amount of timesheets that have been submitted for a given teacher and display it in a field on the teacher object.

How could I go about doing this?

  • are you using a master detail relationship? If you are you could use a roll up summary field, or look on the apex change for the roll up summary helper. – Girbot Sep 7 '14 at 21:45
  • Haha, worked a charm. I spent so much time fiddling with apex code and the solution was so simple, I'm such a n00b. Thanks for that Girbot! – user3808606 Sep 7 '14 at 23:49

Converting my comment to an answer.

If you are using a master detail relationship you could you use the standard roll up summary field, or if you are using a standard lookup you could use the rollup helper on the appexchange - https://appexchange.salesforce.com/listingDetail?listingId=a0N30000009i3UpEAI


Another way (if you are using lookup or if you need more complex counting/or any other logic) is creating a trigger which stores values on the parent record. Note that you should avoid using trigger if you can achieve that by other options. In this case trigger should be created on the child object.

  • thanks for the feedback, I'll try it out when I get more skills ;-) – user3808606 Sep 8 '14 at 21:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.