How to imitate click on Confirm shipment in Acumatica

Hello everybody,

Today I want to describe how to imiate click on menu item "Confirm shipment" in Acumatica. 

Probably your first guess will be just call method ConfirmShiment of graph SOShipmentEntry. But for now Acumatica team has another advice in order to call this action. Instead of calling method ConfirmShipment you'll need to have a bit more steps.

Code sample below demonstrates those necessary steps:

SOShipmentEntry shipmentGraph = PXGraph.CreateInstance<SOShipmentEntry>(); //Create instance of Graph
PXAutomation.CompleteSimple(shipmentGraph.Document.View);
PXAdapter adapter2 = new PXAdapter(new DummyView(shipmentGraph, shipmentGraph.Document.View.BqlSelect,
						 new List<object> { shipmentGraph.Document.Current }));
adapter2.Menu = SOShipmentEntryActionsAttribute.Messages.ConfirmShipment;
adapter2.Arguments = new Dictionary<stringobject>
{
		{"actionID"SOShipmentEntryActionsAttribute.ConfirmShipment}
};
adapter2.Searches = new object[]{shipmentGraph.Document.Current.ShipmentNbr};
adapter2.SortColumns = new[] { "ShipmentNbr"};
soShipmentGraph.action.PressButton(adapter2);
TimeSpan timespan;
Exception ex;
while (PXLongOperation.GetStatus(shipmentGraph.UID, out timespanout ex) == PXLongRunStatus.InProcess)
{ }
//Here you'll have your shipment confirmed

And DummyView looks like this:

public class DummyView : PXView
    {
        List<object> _Records;
        internal DummyView(PXGraph graphBqlCommand commandList<objectrecords)  : base(graphtruecommand)
        {
            _Records = records;
        }
        public override List<objectSelect(object[] currentsobject[] parametersobject[] searchesstring[] sortcolumns
bool[] descendingsPXFilterRow[] filtersref int startRowint maximumRowsref int totalRows)         {             return _Records;         }     }

If you wonder, why calling ConfirmShipment is not enough, answer is this: ConfirmShipment cal will confirm shipment, but it will not execute Automation Steps. Thats why all of mentioned steps are needed. Otherwise, you'll make long research on question, why something doesn't work in the same way, as it works in UI, but doesn't work from my code.

No Comments

Add a Comment