How to create a return order from a sales orders?

Is there a base way to create a return order from a sales order? The scenario I have is we are giving a testing and evaluation product to customers. They have 30 days to decide if they want to buy or return.

I’ll be doing much of this through code…but I’d like to have a sales order created, then create a return order from that sales order. After 30 days the sales order will be invoiced, and the return order will either be processed and a credit applied against to offset the sales order invoice, or the return order will be canceled and we will receive payment.


Why the insistence on the return order, have a negative line with the delivery 30 days +

Return orders bring return reasons, arrival processing, disposition codes etc. Do you need these?

It has to be an RMA. I have been exploring the approach you said, but our business owners need the RMA because of our external systems generating an RMA number, and then not all of the pieces will be returned at once, and there could be high volume, so they want everything to hit the RMA department where it will fit along with the normal process.

I’ve been able to create an RMA, then find a sales order to match it and it will clear out the lines. I was hoping for a way to go to the sales order and just do Functions>Create Return order or something along those lines.

There is no function to “Create Return Order” from the sales order. From the return order there is a get sales order functionality, but the process from an AX perspective is to create the RMA and link it to a sales order, not vice a versa.

If the business insists on hanging it off return orders and the RMA then you need to process through the full return order functionality.

Thanks Adam. Once you create the RMA header, then do Functions>Find Sales Order and choose one order…is there any link after that? It looks like it just copies the lines and reverses the quantites, but there is no actual linking…just purely line copy?

The return lot id is stamped on teh return order line, if you go to main table on this you see the copied from sales order.

Thanks Adam, this is very helpful. I looked at the headers before and wouldn’t have found this relation without your comment. For other reading, the [originalsalesline].InventTransId == [ReplacementSalesLine].InventTransIdReturn.

Below are the basics for creating an RMA from the sales line via X++ for anybody interested. You will need to modify this to make it work, but it’s the basics.:

// Ripped out of Forms\SalesCopying

void writeTmpFrmVirtual(TmpFrmVirtual _tmpFrmVirtual, tableId _tableId, recId _recId, Num _id, LineNum _lineNum = 0, TransDate _transDate = systemdateget(), Qty _qty = 0)


_tmpFrmVirtual.TableNum = _tableId;

_tmpFrmVirtual.RecordNo = _recId;

_tmpFrmVirtual.Id = _id;

_tmpFrmVirtual.LineNum = _lineNum;

_tmpFrmVirtual.TransDate = _transDate;

_tmpFrmVirtual.Qty = _qty;




// Create your RMA header here

// [Put your code here for ReturnOrder]

// End RMA header create

writeTmpFrmVirtual(tmpFrmVirtualHeader, originalSalesTable.TableId, originalSalesTable.RecId, custInvoiceJour.InvoiceId);

while select salesLine

where salesLine.SalesId == originalSalesTable.SalesId










salesCopying = SalesCopying::construct(SalesPurchCopy::CreditNoteHeader);

salesCopying.initParameters(returnOrder, // This is the RMA header, aka SalesTable type









// These two commented lines are used if you are doing this manually





No problem, thanks for the update, hopefully other users will find it useful now and in the future [:D]

Thanks Adam ,

The above reference is very useful .

When it comes to AP , is any there any seperate Purchase return order form like Sales return order from .If yes , what is the path?

No there is no separate purchase return order, just the order type.