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
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

Thanks.

Regards,
Samuel
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.

Steps:

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

Screenshot:

User-added image


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

Screenshot:

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.

Thanks 
D Naveen Rahul.