I created the class below to fire on an Insert/Update trigger on the Opportunity. It is meant to change the Opportunity price book based upon the value entered in a custom picklist on the Opp. Everything saves and runs without error, but nothing gets changed. Am I missing something that would make the update? Thanks,
Public Class ClassSetPriceBook {
public void pbSet(List<Opportunity> SetPB){
ID pb1 = '01sK00000000y6x';
ID pb2 = '01sK00000000y72';
ID pb3 = '01sK00000000y77';
ID pb4 = '01sK00000000y7C';
String Edition1 = 'Edition-1';
String Edition2 = 'Edition-2';
String Edition3 = 'Edition-3';
String Edition4 = 'Edition-4';
for(Opportunity opp : SetPB) {
if (opp.Edition__c == Edition1) {
opp.Pricebook2Id = pb1;
}
else if (opp.Type == Edition2) {
opp.Pricebook2Id = pb2;
}
else if (opp.Type == Edition3) {
opp.Pricebook2Id = pb3;
}
else if (opp.Type == Edition4) {
opp.Pricebook2Id = pb4;
}
}
}
}