+ Start a Discussion
Eric BartzEric Bartz 

Formula or Apex Trigger Needed

I have a parent-child relationship between Contacts and the custom object "Staff Page". A staff page holds our staff information for a given year.

I would like to create a field on the Staff Page that counts the number of other staff pages from previous years that meet a certain criteria to determine when additional pay is awarded. I know I can do this with a roll-up summary on the Contact page to have a live look at the number of qualifying Staff Pages, but I would like for each Staff Page to show the correct number up to that point. For example a 2012 staff page would show the number 2 if that staff member qualified in 2009, 2011 and 2013.

Any thoughts or suggestions?
Pretty sure you'll need a trigger for that.
Eric - depending on the number of years you need covered by this and the number of available Rollup Summary fields left on your Contact object, a possible solution would be to create a series of Rollup Summary fields on the Contact object that would pull the totals for each year plus previous years. The formula field on the Staff Page would then use either CASE or IF statements to reference the correct Rollup based on the year listed on the Staff Page record.

Not the simplest solution, but probably easier than a trigger.
David - Good idea.  Need to make sure the Contact to Staff Page relationship is a Master-Detail.