You need to sign in to do that
Don't have an account?
masthan khan
System.DmlException: Insert failed. First exception on row 0; first error: STANDARD_PRICE_NOT_DEFINED, No standard price defined for this product: []
Hai,
When inserting arecord it is gthrowing following error :
System.DmlException: Insert failed. First exception on row 0; first error: STANDARD_PRICE_NOT_DEFINED, No standard price defined for this product: [];
public class DML_Practice_Usercase4 {
public List<PriceBookEntry> pbe{set;get;}
public List<product2> pb{set;get;}
public list<Pricebook2> pb2{set;get;}
public DML_Practice_Usercase4(){
pbe=new list<PriceBookEntry>();
product2 pb=[select id from product2 where name='salesforce' ];
Pricebook2 pb2=[SELECT id FROM Pricebook2 WHERE Name = 'IndianPricebook'];
PriceBookEntry p1=new PriceBookEntry();
p1.Product2id=pb.id;
p1.Pricebook2ID=pb2.id;
p1.unitprice=10000;
pbe.add(p1);
insert pbe;
}
}
When inserting arecord it is gthrowing following error :
System.DmlException: Insert failed. First exception on row 0; first error: STANDARD_PRICE_NOT_DEFINED, No standard price defined for this product: [];
public class DML_Practice_Usercase4 {
public List<PriceBookEntry> pbe{set;get;}
public List<product2> pb{set;get;}
public list<Pricebook2> pb2{set;get;}
public DML_Practice_Usercase4(){
pbe=new list<PriceBookEntry>();
product2 pb=[select id from product2 where name='salesforce' ];
Pricebook2 pb2=[SELECT id FROM Pricebook2 WHERE Name = 'IndianPricebook'];
PriceBookEntry p1=new PriceBookEntry();
p1.Product2id=pb.id;
p1.Pricebook2ID=pb2.id;
p1.unitprice=10000;
pbe.add(p1);
insert pbe;
}
}
All Answers
Steven Nsubuga,
Its working but what is the relation between isStandard and is Isactive..
why are we inserting record twice.
Regards
Masthan.
There must be an entry in the Standard Pricebook for each Product in Salesforce. This is a Salesforce rule. So whenever you create a new product and a new pricebook, that new product must exist in the standard pricebook before it exists in your new pricebook.