You need to sign in to do that
Don't have an account?
kishore64
System.DmlException: Insert failed. First exception on row 0; first error: STANDARD_PRICE_NOT_DEFINED, No standard price defined for this product: []
Hi all,
Here i am writng the test class like,
@isTest(seeAllData=true)
public class testSyncQuotaLineItemsCls{
public static testMethod void testSyncQuotaLineItemsCls(){
Contact con = New Contact();
con.LastName='test';
insert con;
Opportunity opp = new Opportunity();
opp.Name='test';
opp.CloseDate=Date.Today();
opp.StageName='Prospecting';
opp.Contact_del__c=con.id;
insert opp;
Quote qta = new Quote();
qta.Name='test';
qta.opportunityid=opp.id;
qta.Address_Information__c='Bangalore';
insert qta;
Sales_Order_LineItem__c soli = New Sales_Order_LineItem__c();
soli.Name='test';
insert soli;
Product2 pr = New Product2();
pr.Name='test';
pr.IsActive=true;
insert pr;
PriceBook2 pb2 = New PriceBook2();
pb2.Name = 'test';
pb2.IsActive=true;
// pb2.IsStandard=true;
insert pb2;
Pricebook2 p =[Select p.Id, p.Name from Pricebook2 p where isActive = true AND isStandard=true Limit 1];
PricebookEntry pb = New PricebookEntry();
pb.Product2Id = pr.Id;
pb.PriceBook2Id = pb2.id;
pb.UseStandardPrice = true;
pb.UnitPrice=35;
pb.isActive=true;
insert pb;
PricebookEntry pb1 = [select id,name,usestandardprice from PricebookEntry where usestandardprice=true];
QuoteLineItem qli = New QuoteLineItem();
qli.Product2Id=pr.id;
qli.UnitPrice=12;
qli.Quantity=5;
qli.QuoteId=qta.id;
qli.UnitPrice=35;
// qli.ListPrice=410;
//qli.Subtotal=123;
//qli.TotalPrice=410;
qli.PricebookEntryId=pb.id;
insert qli;
string qtaid = qta.id;
SyncQuotaLineItemsCls sqli = New SyncQuotaLineItemsCls();
SyncQuotaLineItemsCls.syncQLItoSLI(qtaid);
}
}
Error is: System.DmlException: Insert failed. First exception on row 0; first error: STANDARD_PRICE_NOT_DEFINED, No standard price defined for this product: []
Here where i did mistake i don't know . please help me out .
Advance Thank you.
Here i am writng the test class like,
@isTest(seeAllData=true)
public class testSyncQuotaLineItemsCls{
public static testMethod void testSyncQuotaLineItemsCls(){
Contact con = New Contact();
con.LastName='test';
insert con;
Opportunity opp = new Opportunity();
opp.Name='test';
opp.CloseDate=Date.Today();
opp.StageName='Prospecting';
opp.Contact_del__c=con.id;
insert opp;
Quote qta = new Quote();
qta.Name='test';
qta.opportunityid=opp.id;
qta.Address_Information__c='Bangalore';
insert qta;
Sales_Order_LineItem__c soli = New Sales_Order_LineItem__c();
soli.Name='test';
insert soli;
Product2 pr = New Product2();
pr.Name='test';
pr.IsActive=true;
insert pr;
PriceBook2 pb2 = New PriceBook2();
pb2.Name = 'test';
pb2.IsActive=true;
// pb2.IsStandard=true;
insert pb2;
Pricebook2 p =[Select p.Id, p.Name from Pricebook2 p where isActive = true AND isStandard=true Limit 1];
PricebookEntry pb = New PricebookEntry();
pb.Product2Id = pr.Id;
pb.PriceBook2Id = pb2.id;
pb.UseStandardPrice = true;
pb.UnitPrice=35;
pb.isActive=true;
insert pb;
PricebookEntry pb1 = [select id,name,usestandardprice from PricebookEntry where usestandardprice=true];
QuoteLineItem qli = New QuoteLineItem();
qli.Product2Id=pr.id;
qli.UnitPrice=12;
qli.Quantity=5;
qli.QuoteId=qta.id;
qli.UnitPrice=35;
// qli.ListPrice=410;
//qli.Subtotal=123;
//qli.TotalPrice=410;
qli.PricebookEntryId=pb.id;
insert qli;
string qtaid = qta.id;
SyncQuotaLineItemsCls sqli = New SyncQuotaLineItemsCls();
SyncQuotaLineItemsCls.syncQLItoSLI(qtaid);
}
}
Error is: System.DmlException: Insert failed. First exception on row 0; first error: STANDARD_PRICE_NOT_DEFINED, No standard price defined for this product: []
Here where i did mistake i don't know . please help me out .
Advance Thank you.
All Answers
I am doing in your way Now again i am executing this test class it shows some other exception i,e.
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: []
Then what can i do, i want to chnage any other thing please let me know......
Let say as you have a Account lookup field on Contact and you want to insert a new contact by assigning an Opportunity id to the Account field on Contact and try to perform a DML then you'll get this Exception.
Please check in your code where you are getting this exception and assign a valid id for that field which is expected by that field.