2

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?

The original order is not a reduction order though enter image description here

enter image description here

  • 1
    The error message seems pretty clear. Is originalOrder also a reduction? – Adrian Larson May 2 at 13:43
  • Yes, it is clear with the message but it is not the case. I've added one screenshot of the original order. Please check. Also, if there is error then how the reduction order is being created successfully? – Anant May 2 at 14:08
  • Are you absolutely certain that is the right field? It's not per chance some custom field with a similar label? – Adrian Larson May 2 at 14:25
  • Yes, I am sure about it. I have added one more screenshot for Order fields. You can check – Anant May 3 at 5:19
  • Seems like a bug. I recommend you open a case with support. – Adrian Larson May 3 at 5:37
0

ok, I get this. there were some more reduction orders which were being created in my code in a loop and the first reduction order is replacing the 'orginalorderId' for next reduction order. So the error is returning for the next reduction order in a loop.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.