Skip to content

Instantly share code, notes, and snippets.

@eddywebs
Created September 5, 2017 16:53
Show Gist options
  • Save eddywebs/3fded178c19a17faaba03821ce6d6ea4 to your computer and use it in GitHub Desktop.
Save eddywebs/3fded178c19a17faaba03821ce6d6ea4 to your computer and use it in GitHub Desktop.
Pricebook2 pb = new Pricebook2(Name = 'Standard Price Book 2009', Description = 'Price Book 2009 Products', IsActive = true );
insert pb;
Product2 prod = new Product2(Name = 'SLA: Bronze', IsActive = true);
insert prod;
// First insert a price for the standard price book
Pricebook2 standardPB = [select id from Pricebook2 where isStandard=true];
PricebookEntry standardPBE = new PricebookEntry(Pricebook2Id = standardPB.Id, Product2Id = prod.Id, UnitPrice = 1000, IsActive = true);
insert standardPBE;
PricebookEntry pbe = new PricebookEntry(Pricebook2Id = pb.Id, Product2Id = prod.Id, UnitPrice = 1000, IsActive = true);
insert pbe;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment