+ Start a Discussion
Samuel Gonsalves 8Samuel Gonsalves 8 

Trigger / Workflow to update a field in account based on field value of opportunity

Hi All,
I have a ‘Status’ field in Accounts with values below
1. Inactive
2. Active
3. New
4. Reactivated
Can we automate the following:
a. Change the status of an Account with ‘Active’ status to ‘Inactive’ if they haven’t had an opportunity closed won in the last 12 months
b. Change the status of an Account with ‘Inactive’ status to ‘Reactivated’ as soon as the Account has a Closed Won opportunity


PratikPratik (Salesforce Developers) 
Hi Samuel,

a. For this part you will have to write schedule apex to check the opportunity over 12 months for it's stage.

b. This you can achieve through Workflow Rule.


1.Create a workflow rule on Opportunity, with Rule criteria
Stagename="Closed won"


User-added image

2. Create a Field update action on this workflow to change the account status.


User-added image

Hope this will help.
Naveen Rahul 3Naveen Rahul 3
HI samuael,

 modified a bit,you can use this tested working well.

A. (NOT(ISPICKVAL(StageName,'Closed Won')) && (Today()-CloseDate > 365) )  Formulla expression
B. (Account: ActiveequalsNo) and (Opportunity: StageequalsClosed Won)   When criterias met.

you just need to select field update carefully thats all.

Please let me know anything thats needed.

D Naveen Rahul.