I am trying to create a reduction order for an already created order. Though reduction order is being created successfully, it is returning this error:
Refund Order Error: field integrity exception: OriginalOrderId (reduction orders may not reference other reduction orders for reduction)
I have correctly passed the required parameters as:
Order reductionOrder = new Order( IsReductionOrder = true, OriginalOrderId = originalOrder.Id, Pricebook2Id = originalOrder.Pricebook2Id, EffectiveDate = originalOrder.EffectiveDate, Status = 'Draft', AccountId = originalOrder.AccountId); insert reductionOrder;
Why do I get this error? How can I fix it?