You need to sign in to do that
Don't have an account?
John Neilan
Trigger to Update Opportunity Price Book
Hello,
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,
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; } } } }
Can you please share your trigger code as well?
It's a Before Insert, Before Update trigger
I think your would be something like that:
trigger triggername on Opportunity(before insert, before update)//make sure these events are added.
{
ClassSetPriceBook updater3 = new ClassSetPriceBook();
if(Trigger.isBefore)
{
if(Trigger.isInsert)
updater3.pbSet(Trigger.new);
}
}