Last active
November 6, 2017 14:35
-
-
Save sfdcfanboy/fc595afc878e1c7e65127237b1677fa5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//product1 | |
Product2 p = new Product2(); | |
p.Name = 'Test Product'; | |
p.Description = 'Test desc'; | |
p.IsActive = true; | |
insert p; | |
//standard price book entry for Product p | |
PricebookEntry pbe1 = new PricebookEntry(); | |
pbe1.Pricebook2Id = Test.getStandardPricebookId(); | |
pbe1.IsActive = true; | |
pbe1.Product2Id = p.Id; | |
pbe1.UseStandardPrice = false; | |
pbe1.CurrencyISOCode = 'SGD'; | |
pbe1.UnitPrice = 100; | |
insert pbe1; | |
//custom pricebook | |
PriceBook2 pb = new PriceBook2(); | |
pb.Name = 'Custom PB'; | |
pb.IsActive = true; | |
insert pb; | |
//custom pricebook entry for p1 | |
PricebookEntry pbe = new PricebookEntry(); | |
pbe.Pricebook2Id = pb.Id; | |
pbe.IsActive = true; | |
pbe.Product2Id = p.Id; | |
pbe.UseStandardPrice = false; | |
pbe.CurrencyISOCode = 'SGD'; | |
pbe.UnitPrice = 100; | |
insert pbe; | |
//update Pricebookentry to use Standard Price | |
pbe.UseStandardPrice = true; | |
update pbe; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment