Unfortunately, I'm not able to use simple Validation Rules to do my conditional statement validation. Instead I have to use a trigger to do so.
That being said, currently, I'm trying to only run this trigger on certain profile types. We have different records for our Opportunities and I only want it to run on, for example 'SGIOpportunities'. Here is the current code I have:
trigger UpdateOpportunity on Opportunity (before insert, before update){
Set<String> recordTypeToValidateAgainst = new Set<String>();
recordTypeToValidateAgainst.add('SGIOpportunities'); // SGI Opportunity Type
for(Opportunity opp: trigger.new){
if(recordTypeToValidateAgainst.contains(Schema.RecordTypeInfo.getName()) && opp.StageName != '0 %'){
OpportunityMethods.updateOppCompetitor(opp);
}
}
}
**OpportunityMethods.updateOppCompetitor(opp)
is declared in an APEX class, that are my conditional statements.
Also the error I'm getting in the compiler is:
Error: Compile Error: Method does not exist or incorrect signature: Schema.RecordTypeInfo.getName() at line 7 column 49
Note: I do have the fully qualified name: Schema.RecordTypeInfo.getName() listed and not sure why it's not able to get the value..
Thanks for you help in advance!