function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Chrissy Thompson 12Chrissy Thompson 12 

Apex Trigger to Update Custom field based on Current Date?

We have a field for Q1 Stage, Q2 Stage, Q3 Stage, Q4 Stage. We need someone (Apex Trigger?) to input the Opportunity Stage as soon as Q1 begins, Q2, etc. Once populated, keep as is even if the stage changes throughout that quarter. This should fire regardless if it's edited (just in case an Opportunity sits in the same stage for several quarters and no edits are made). Originally, we were going to use a Process Builder, but this will not account on date without an edit being made. We need the system to know it's the beginning of a quarter, please add the current Opp Status to field. Any suggestions?

Example: 
Q1 Stage = Prospect
Q2 Stage = Proposal
Nayana KNayana K
Apex trigger will also have the same problem (will not account on date without an edit being made).

I think you can go for schedule apex batch which runs every 1st of 3 months (https://salesforce.stackexchange.com/questions/65248/run-apex-scheduler-quarterly)

Then in the batch start(), query all opportunities and execute the (Q1 Stage = Prospect
Q2 Stage = Proposal) logic.