You need to sign in to do that
Don't have an account?

How do i write a batch class and trigger on account status to change based on a formula field update happened
Hi Everyone,
Can anyone please help me on how to write a batch class and/or trigger on account status update for below requirement.
I'm pretty new to coding so not sure where to start it from.
Usecase--
Create a batch job that will run hourly with the following functionality:
For any Strategic Supplier Accounts...
1. If the Account.of_Awarded_Divisions_c > 0 and Account.Status != Awarded, Do Not Contact, or Ineligible, then update the Account.Status_c to Awarded
2. If the Account.of_Awarded_Divisions_c = Account.of_Divisions_ever_having_APc, then update the Account.Status_reason_c to Full Award
Can anyone please help me on how to write a batch class and/or trigger on account status update for below requirement.
I'm pretty new to coding so not sure where to start it from.
Usecase--
Create a batch job that will run hourly with the following functionality:
For any Strategic Supplier Accounts...
1. If the Account.of_Awarded_Divisions_c > 0 and Account.Status != Awarded, Do Not Contact, or Ineligible, then update the Account.Status_c to Awarded
2. If the Account.of_Awarded_Divisions_c = Account.of_Divisions_ever_having_APc, then update the Account.Status_reason_c to Full Award
There is an idea (that seems to be languishing) for this functionality you can vote on:
https://success.salesforce.com/ideaview?id=08730000000BrIGAA0
As for the more general response to what to code, why does the code need to run hourly as a batch? Because there is a another object that does an update which is then reflected in one of the fields on Account? It seems you are doing a simple field update based on criteria. Why not do a Process Builder from the Original record that is causing the formula change on the Account record?
For example, if the Division is an object that updates and then relates to a field on the Account, do a process builder on the Division object to update the Status field when it fulfills the requirements of the computed field.
Regards
Andrew