What to use as "Price Book Entry ID" on a new Order Item

I am building an order entry page. It creates a new order ok and I then have a search box on a table to find suitable products. I want a selected product to be added as an Order Item and have designed an action that creates a new record on the order item object but cant find the correct field from the selected product to enter as “Price Book Entry ID”? Can anyone point me in the right direction?

You are probably looking directly up to Products in your table search.  I think you need to lookup to a single pricebook instead.  Then each product in the pricebook will have a pricebookEntryId…

Salesforce designs it this way to allow several pricing options for your products.   But it does complicate the data model… 

Hi Rob,

I got to that point ok. I have am hitting a wall in passing the order id to the order product record.

I have two models - “NewOrder” and “Order Products”   -  the first creates a new order ok. I am just using the standard price book so have its’ ID to insert in the order ok also.

The Order Product model has a condition that is filterable but off that takes order id from the new order model.

I have a button that creates a new order product, it inserts the pricebook id ok, it activates the order product condition and then I enter product id and quantity and unit price.

I get the attached error - but as admin I have access etc 

I realise it may be tough to follow but any tips would be great as to any other way to get the order id into the order product which seems to be the problem.

The error I cant get passed says “Insufficient access rights on cross reference ID”

That error message usually means you are trying to update a record with a value that is not logically possible, either because you don’t have rights to it (not the case here) or because it isn’t the kind of object that goes there.  I’d do some digging on existing records to see what kind of value is actually legitimate in the Order.Pricebook2.Id field.  You may have the wrong field,  you may have the wrong kind of object that is being passed into the field.