I am trying to create an orderitem from visualforce page and I am getting an error > Attempt to de-reference a null object while assigning pricebookentry.priduct2Id.Here is my part of code where it is failing. for(OrderItem oi:selectedOItems){ OrderItem o = new OrderItem(); o.PricebookEntry.Product2Id = oi.PricebookEntry.Product2Id; //error on this line o.Quantity = oi.Quantity; o.unitPrice = oi.UnitPrice; o.orderId = oId; oItemsToInsert.add(o); } How should I assign product to OrderItem ?