-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprice.cls
31 lines (28 loc) · 1.03 KB
/
price.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//Create new price book 'Algo Price Book' and 10 products with Prices in the Pricebook
public class price {
public static void getPrice(){
Pricebook2 cpb = new Pricebook2(name = 'Algo Price Book', IsActive = True);
Insert cpb;
List<Product2> prodList = new List<Product2>();
for(Integer i=0; i<10;++i)
{
Product2 pro = new Product2(Name = 'Product testing 1:' + string.valueOf(i));
prodList.add(pro);
}
if(!prodList.isEmpty())
{
Insert prodList;
}
List<PricebookEntry> pbeList = new List<PricebookEntry>();
for(Product2 product : prodList){
PricebookEntry pbe = new PricebookEntry(Pricebook2Id = cpb.Id,
IsActive=True, Product2Id = product.Id,
UnitPrice= 240);
pbeList.add(pbe);
}
if(!pbeList.isEmpty())
{
Insert pbeList;
}
}
}