I have the following trigger:
trigger UpdateOpportunity on Opportunity (before insert, before update){
Opportunity[] oppQuery = [SELECT ID, RecordType.Name, StageName, Win_Reason__c, Unsolicited_Bid__c, Competitor_s__c FROM Opportunity WHERE ID IN :Trigger.new];
for(Opportunity opp : oppQuery){
if(opp.RecordType.Name == 'SGI Opportunity' && opp.StageName != 'Lead 0%'){
System.debug('THIS WORKED1');
if(opp.Win_Reason__c == 'No Competition/Sole Source'){
opp.Competitor_s__c = 'No Competitor/Sole Source';
System.debug('THIS WORKED2');
}
if(opp.Unsolicited_Bid__c == 'Yes'){
opp.Competitor_s__c = 'No Competitor/Sole Source';
System.debug('THIS WORKED3');
}
}
}
}
To explain the trigger, I want it to only run when the RecordName is 'SGI Opportunity' and if StageName doesn't equal 'Lead 0%' If that is the case then if Win Reason = Yes then then opp.Competitor_s__c = 'No Competitor/Sole Source' and/or if Unsolicited Bid = 'Yes' then Competitor_s__c = 'No Competitor/Sole Source'. I've set up my user to make debug logs and I'm seeing my System.debug comments, but it's not automating the selection of the multi select Competitor picklist for me. I'm not certain at why my code isn't working correctly..
Thanks in advance for your time!