You need to sign in to do that
Don't have an account?
Darshit Pathak 3
Why PricebookEntry Id is accepted instead of Product Id while creating OrderItem record in apex?
OrderItem object is a junction of Order and a product.
It has 2 lookup fields , 1 for Order (API : OrderId) and 1 for Product (API : Product2Id)
But when we try to create record of OrderItem it throws error Product2Id field does not exists.
Instead it's accepting "PricebookEntryId".
As per scheme it should accept Product Id and not the pricebookEntry Id.
It has 2 lookup fields , 1 for Order (API : OrderId) and 1 for Product (API : Product2Id)
But when we try to create record of OrderItem it throws error Product2Id field does not exists.
Instead it's accepting "PricebookEntryId".
As per scheme it should accept Product Id and not the pricebookEntry Id.
Pricebook refers to the price list of the products/entities for different regions.
PricebookEntryId refers to the price of a product from specified pricebook.
Hence the OrderItem accepts the pricebook entry id refering to the product from a specified pricebook rather than a generalized product.
I agree on what you said but what I am not able to digest is , if PricebookEntry is required there then why lookup field would have been created by sfdc to refer Product2 Object? how would a developer know by looking at schema of OrderItem that he needs to populate Pricebookentry id instead of Product Id.