i have a requirement that, if i insert new product then the newly created product must associate to all the pricebooks(including std and custom) but i get and error as illegal assignment from list to string i have tried the below code.
String pricebkId= [SELECT id,isStandard from Pricebook2];
List<PricebookEntry> pbeList = new List<PricebookEntry>();
for(Product2 p: Trigger.New){
pbeList.add(new PricebookEntry(
UnitPrice = 10,
Pricebook2Id = pricebkId,
product2Id = p.Id,
isActive = true));
}
insert pbeList;
Thanks