+ Start a Discussion

Mass Update All Records in a Custom Object



I have created 2 triggers:


Trigger #1 fires on the Opportunity and updates a field on a custom object called Population_Assumption__c;


Trigger #2 fires on the Population_Assumption__c custom object and updates a number of fields on the Opportunity object based on the values in each Population_Assumption__c record.


I ultimately need these 2 triggers to fire in succession, but after numerous calls to support I've realized that it cannot happen as it would be an unending loop.  However, support has told me that I can use a Visualforce page where my users can click a button to fire Trigger #2 after they update the Opportunity field manaually.


What I'm trying to do is to replicate the user opening each Population_Assumption__c record and saving it (no changes), which will then fire trigger #2 and update the Opportunity object.  Does anyone have any sample code that I can use as a starting point to achieve this?  I'm very new to Visualforce pages.  I've seen some code that includes an input screen, but I am just looking for something that will update all the records in the Population_Assumption__c object without requiring the user to check the ones they want to update.  Any assistance is appreciated.  Thanks!


In your original scenario of two triggers, you can use a static variable to indicate that the first trigger should only fire the first time through, and not when the opportunities are updated via the second trigger.  


This technique is documented at: