Reputation: 61
I'm trying to process return orders in Acumatica, for which I will have to create a Sales Order of type RC, invoke the Create Receipt Action on the sales order which creates a shipment of type Receipt and then invoke Confirm Shipment on the shipment. However in the list of Actions defined on the Sales Order, I do not find an action corresponding to Create Receipt. Can anyone guide me on how to invoke the Create Receipt action programatically as we do through the screen?
For e.g. this is how I invoke Confirm Shipment on a shipment and looking for something similar to Create Receipt:
var adapter = new PXAdapter(graph.CurrentDocument);
adapter.Arguments.Add("actionID", SOShipmentEntryActionsAttribute.ConfirmShipment);
PXLongOperation.StartOperation(graph, delegate ()
{
foreach (SOShipment soShipment in graph.action.Press(adapter)) ;
});
Upvotes: 0
Views: 800
Reputation: 1864
This is a solution previously provided by Acumatica, I tried this method in few screens and it was working. In the following code try to change the graph to your SOOrderEntry and Command to "Create Receipt"
docgraph.Document.Current = docgraph.Document.Search<SOShipment.shipmentNbr>("mYsHIPMENTnUMBER");
docgraph.Cancel.Press();
foreach (var action in (docgraph.action.GetState(null) as PXButtonState).Menus)
{
if (action.Command == "Confirm Shipment")
{
PXAdapter adapter2 = new PXAdapter(new DummyView(docgraph, docgraph.Document.View.BqlSelect, new List<object> { docgraph.Document.Current }));
adapter2.Menu = action.Command;
docgraph.action.PressButton(adapter2);
}
}
internal class DummyView : PXView
{
List<object> _Records;
internal DummyView(PXGraph graph, BqlCommand command, List<object> records)
: base(graph, true, command)
{
_Records = records;
}
public override List<object> Select(object[] currents, object[] parameters, object[] searches, string[] sortcolumns, bool[] descendings, PXFilterRow[] filters, ref int startRow, int maximumRows, ref int totalRows)
{
return _Records;
}
}
Upvotes: 4