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.

Revisions

  1. eddywebs created this gist Sep 5, 2017.
    10 changes: 10 additions & 0 deletions Insert prodcts in salesforce
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    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;