The standard Order object has a read-only checkbox/Boolean field called IsReductionOrder that is defined as:
Read-only. Determines whether an order is a reduction order. Label is Reduction Order.
I have code to create a reduction Order as follows, but it doesn't work because the IsReductionOrder fields is read-only, which is consistent with the documentation.
Order originalOrder = getExistingOriginalActivatedOrderSomehow(); Order reductionOrder = new Order( IsReductionOrder = true, OriginalOrderId = originalOrder.Id, Pricebook2Id = originalOrder.Pricebook2Id, EffectiveDate = originalOrder.EffectiveDate, Status = 'Draft' AccountId = originalOrder.AccountId, ); insert reductionOrder;
If I remove that line, I get an error that the OriginalOrderId field can only be used with reduction Orders (FIELD_INTEGRITY_EXCEPTION, You can specify Original Order on reduction orders only.: ).
Question: How can I create a reduction Order programmatically?
Definitely need it for unit tests. I'm on Spring '14 with code that is API version 30.