You need to sign in to do that
Don't have an account?
Filipe Baradelli
REQUIRED_FIELD_MISSING: [Quantity]: [Quantity]
Hi,
I'' m trying to put the value of Quantity from Catalog_Line_Item__c to 'Quantity' from Opportunity.
This is the error message. that appeats when I Execute the Catalog:
Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING: [Quantity]: [Quantity].
Can someone help me?
Thanks.
I'' m trying to put the value of Quantity from Catalog_Line_Item__c to 'Quantity' from Opportunity.
/* * updateQuantity(String ID) * Updates the Quantity field of the Catalog Line Item with the given Id */ public PageReference updateQuantity() { if(!Catalog_Line_Item__c.sObjectType.getDescribe().isUpdateable()) { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL,'Insufficient access')); return null; } li = [SELECT Quantity__c FROM Catalog_Line_Item__c WHERE Id =: productId LIMIT 1]; li.Quantity__c = productQuantity; update li; update myOrder; quantity = li.Quantity__c; // Stay on current page return null; }(variable 'quantity' is double)
// Add product and Pricebook to the particular opportunity using OpportunityLineItem OpportunityLineItem oppLineItem = new OpportunityLineItem(); oppLineItem.OpportunityId = opp.Id; oppLineItem.PricebookEntryId = customPriceBookEntry.Id; oppLineItem.UnitPrice = customPriceBookEntry.UnitPrice; oppLineItem.Quantity = quantity ; insert oppLineItem;
This is the error message. that appeats when I Execute the Catalog:
Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING: [Quantity]: [Quantity].
Can someone help me?
Thanks.
Could you please check the quantity varibale value before assigning to oppLineItem.Quantity. Seems like a Null value is getting assiged to Opporunity line item and it is throwing an error.
Thanks,
Ishwar
Please mark this as the best answer if this helps!!
Can you debug and check for the value of productQuantity and also I would recommend you to include the update in a try catch block so that the runtime exceptions could be handled.
Regards,
Akash.
It should work as Double.valueOf(your_field_name) or Double.valueOf(string_value).
quantity is double
I put the following code:
The error continues. Appears that it is not null and the command Double.ValueOf(quantity) is not working.
I don't know why it is null, the variable 'li' (the query) is public and is working for the other parts.
Variable 'quantity' is declared: public Catalog_Line_Item__c quantity = new Catalog_Line_Item__c();
( like 'li')
The oppLineItem.Quantity is resulting 2.
public Catalog_Line_Item__c quantity = new Catalog_Line_Item__c();
This is storing a Catalog_Line_Item__c value and not just a double quantity. This does not seem to make sense for my previous understanding of what you were doing in the code. Further, in this new code you pull the same record into li and quantity, so update li and update quantity are repititious. What is the point?
Anyway, to understand why quantity is failing the IF condition in the second code block, I would need to see the full code for both files if this is not in one file. As seeing this in this fashion is hindering our ability to help you here.
You can try below code -
Here is the full code:
You are receiving that error because of parameter used in query - productId. Your page is not maintaining state, which causes to resetting of variable value. Because of this, query is not retruning any value to you.
Please share the page code and the sequence which you follow to perform this activiity? It will be good if you share the controller method which is getting called on each activity.