You need to sign in to do that
Don't have an account?
Teasha
Apex Trigger Help
Can someone help me with the code for a trigger that rolls up opportunity values into a custom object? For example:
Custom Object = Forecast_C
Custom Object Field to update = Q1_Bookings_c
The information will come from
Opportunity Object Fields
Closed_To_Date_C + (Opportunities at the stage Closed Won) - With a close date in current FQ
Any help?
If I'm understanding you correct then this trigger should only need to fire from an Opportunity when it goes Closed Won. It will then increment the number in the Q*_Bookings__c field based on which quarter it falls in within the fiscal calendar.
You will definitely need to write some additional business logic where I highlighted in red below, but this should get you started. I've commented up the code to help you understand how the logic flows.
Its also worth noting that you may want to consider expanding the trigger to update the related forecast records on delete and undelete as well.
Let us know if you have any questions!
All Answers
Yes, there is a look up on opportunity to the custom object
If I'm understanding you correct then this trigger should only need to fire from an Opportunity when it goes Closed Won. It will then increment the number in the Q*_Bookings__c field based on which quarter it falls in within the fiscal calendar.
You will definitely need to write some additional business logic where I highlighted in red below, but this should get you started. I've commented up the code to help you understand how the logic flows.
Its also worth noting that you may want to consider expanding the trigger to update the related forecast records on delete and undelete as well.
Let us know if you have any questions!