Not sure if my syntax is correct, what I'm trying to achive is updating a text field (X80_20__c
), where the data is coming from a formula text field (X80_20_Yes_or_No__c
). The output from the formula field produces a Yes or No value.
This is the Apex trigger I attempted but its not populating the X80_20__c field. Any help would be appreciated or would a Apex Class be better to do in this situation? Also, I'm avoiding in using a workflow trigger or process builder for this.
trigger a8020 on Account (before insert,before update) {
List obj = [SELECT Id,Name,X80_20_Yes_or_No__c,X80_20__c FROM Account WHERE
(X80_20_Yes_or_No__c = 'Yes' OR X80_20_Yes_or_no__c = 'No') AND
Outlet_Type__c = 'Home Depot' AND Has_1_2_3x5_DULO__c = 'Yes' ];
for (Account a: obj) {
string s = a.X80_20_Yes_or_No__c;
a.X80_20__c = s;
}
update obj;
}