Hi,
It depends on what you want, but we usually do this:
OrderForm returnForm = purchaseOrder.ReturnOrderForms.AddNew(); returnForm.Name = OrderForm.ReturnName; returnForm.OrigOrderFormId = purchaseOrder.OrderForms[0].OrderFormId; returnForm.ReturnType = ReturnType.Refund; returnForm.Status = ReturnFormStatus.AwaitingStockReturn.ToString(); returnForm.RMANumber = returnForm.ReturnFormNumberMethod(returnForm); returnForm.CreatorId = PrincipalInfo.CurrentPrincipal.GetContactId().ToString(); return returnForm;
So you can ensure some information is more correct this way.
Regards,
/Q
I tried what your suggested but also added a LineItem to the return order. Futrhermore, I called the AcceptChanges() on the returnOrder to acctually save the order in the database. This created a return order, but it seemed corrupted as i tried to edit it from the Commerce Manager it produced an exception. This error revealed that there is a ReturnExchangeManager available in the SDK which implements the procedure Mr Mai suggested which is more comfortable to me.
This is how I used the ReturnExchangeManager:
private void createRefundForm(PurchaseOrder Order, int index, int returnQuantity, String returnReason) { OrderForm returnForm = ReturnExchangeManager.AddNewReturnFormToPurchaseOrder(Order); ReturnExchangeManager.AddNewReturnLineItemToReturnForm( returnForm, Order.OrderForms[0].LineItems[index], returnQuantity, returnReason); returnForm.AcceptChanges(); }
Where Order is the order to return and the index is the index of the lineitems to return
Henrik
Hi
Is it possible to create and add a return order to a PurchaseOrder programmatically?
I was thinking about Doing it manually, something like:
But is this a bad idea?
We run EPiServer 7.5
Henrik Rasmussen