You need to sign in to do that
Don't have an account?

first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: Quantity (quantity must be nonzero): [Quantity]
Hi Experts,
I am getting the below error when I insert Opportunity Line Item in Test Class for trigger. Kindly help me how to rectify this error. Because of this my Code coverage is 70%.
first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: Quantity (Quantity mus be nonzero): [Quantity]
Your inputs are needed.
Thanks
I am getting the below error when I insert Opportunity Line Item in Test Class for trigger. Kindly help me how to rectify this error. Because of this my Code coverage is 70%.
first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: Quantity (Quantity mus be nonzero): [Quantity]
Your inputs are needed.
Thanks
Greetings to you!
Salesforce does not allow specific fields (i.e. opportunity line items value) to have a value of 0, please change the quantity to a non-zero number.
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
Below is my Test Class. I am still getting this error.
@isTest(SeeAllData=true)
public class insertOppsLineitemTest {
static testMethod void testorderItems() {
Opportunity opp = [SELECT Id, Name FROM Opportunity WHERE Name ='Sample'];
Pricebookentry pbe = [SELECT Id, Name FROM Pricebookentry WHERE Name = 'Sample Product'];
orderItems__c oit = [SELECT Id, Name, Name__c FROM OrderItems__c WHERE Name__c = 'Testing'];
Opportunitylineitem oilt = [SELECT Id, Name__c FROM Opportunitylineitem WHERE Name__c = 'Sample Product'];
OpportunityLineItem item = new OpportunityLineItem(
pricebookentryid=pbe.Id,
TotalPrice=2000,
Quantity = 2,
OpportunityID = opp.Id
);
insert item;
oilt.UnitPrice = 0;
update oilt;
}
}
Thanks.
Can you set UnitPrice to a non-zero number?
Thanks