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

OrderItem product2 read only
In trying to utilize the Order and OrderItem objects, I want to create an Order record from an Opportunity that is moved to Booked/Ordered Stage. That is done, no problem.
However, when I try to then replicate the line items from the Opportunity over to the Order record, using the bare minimum, Qty, Price, Product, I get the following UI error:
Looking at the OrderItem and the ContractLineItem objects, I can see that Product2 is READ ONLY on OrderItem, but not in ContractLineItem. How can I change this or code around it?
However, when I try to then replicate the line items from the Opportunity over to the Order record, using the bare minimum, Qty, Price, Product, I get the following UI error:
Error: Invalid Data. Review all error messages below to correct your data. Apex trigger Order3_OrderItemCreate caused an unexpected exception, contact your administrator: Order3_OrderItemCreate: execution of BeforeUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []: Trigger.Order3_OrderItemCreate: line 47, column 1I have narrowed the access error down to the Product field. In the trigger, I am using the PriceBookEntryId (same as I have done in the past for ServiceContract/ContractLineItem objects.
Looking at the OrderItem and the ContractLineItem objects, I can see that Product2 is READ ONLY on OrderItem, but not in ContractLineItem. How can I change this or code around it?
All Answers
But having turned this on in my org, what I see is that OrderItem.PriceBookEntryId has the Creatable attribute set to true, but the Updateable attribute set to false.
Ostensibly, what this would mean would be that you could insert a new OrderItem record with PriceBookEntryId, but if any of your code attempted to update this field in any way, you would receive an error.
In the act of replicating, are any of your flows attempting to perform an update or upsert operation?
Thanks for helping. The Trigger I have for inserting the line items is triggered off a change on the Order itself. It is only performing an insert. Here is the complete trigger (note: when working, it will only be an "after insert" trigger. I have after update in place now just so I can update an Order and test if the line items get created).
Hold on a bit. I think there is a problem with the associated Price Book itself. The original trigger that created the order may be the source of the downstream error. I will work on this and update here if I need assitance.
Glenn