How to modify Process Shipments screen in Acumatica

Hello everybody,

recently I was asked to modify behavior of Process shipments screen in Acumatica. Issue was the following: in case if one of the rows on Process shipments generated error, it was needed to show on the status of processing.

Default behavior was like showed on the screenshot:

as you can see on the screenshot, despite errors were generated on the row level, whole status of processing is fine ( green in the top ).

Of course for my QA such kind of behavior is weird and he asked me to fix it. 

Such behavior happens because Process shipments screen ( SO503000 ) uses PXProcessing.SetProcessTarget() to set the processing delegate which doesn't care at all about errors in the lines.

In such cases it means that you need somehow to say to PXProcessing, please take care of errors in the lines. It can be achieved in the following way:

1.  Create yours PXProcessing, that takes care about lines via inheriting from Acumatica created PXProcessing

2. Substitute standard Orders of SOInvoiceShipment view with your extension from point 1.

Point 1 looks like this:

public class PXCustomFilteredProcessing<TableFilterTable> : PXFilteredProcessing<TableFilterTable>
    where FilterTable : classIBqlTablenew()
    where Table : classIBqlTablenew()
{
    protected ProcessListDelegate _BaseProcessDelegate;
 
    protected PXCustomFilteredProcessing() : base()
    {
    }
 
    public PXCustomFilteredProcessing(PXGraph graph) : base(graph)
    {
    }
 
    public PXCustomFilteredProcessing(PXGraph graph, Delegate handler) : base(graph, handler)
    {
 
    }
 
    // hook processing delegate and inject error reporting logic
 
    protected override void _SetProcessTargetInternal(string graphType, string stepID, string action, string menu, IEnumerable parameters)
    {
        base._SetProcessTargetInternal(graphType, stepID, action, menu, parameters);
 
        _BaseProcessDelegate = _ProcessDelegate;
        _ProcessDelegate = delegate (List<Table> list)
        {
            _BaseProcessDelegate(list);
 
            PXProcessingInfo info = PXLongOperation.GetCustomInfoForCurrentThread("PXProcessingState"as PXProcessingInfo;
            if (info != null)
            {
                PXProcessingMessagesCollection messages = info.Messages;
                for (var i = 0; i < messages.Length; i++)
                {
                    PXProcessingMessage rowInfo = (PXProcessingMessage)messages.Get<SOShipment>(i);
                    if (rowInfo != null && rowInfo.ErrorLevel == PXErrorLevel.RowError)
                        throw new PXOperationCompletedWithErrorException(ErrorMessages.SeveralItemsFailed);
                }
            }
        };
    }
}

Point 2 has much smaller amount of code:

public class SOInvoiceShipmentExt : PXGraphExtension<SOInvoiceShipment>
{
    [PXFilterable]
    public PXCustomFilteredProcessing<SOShipmentSOShipmentFilter> Orders;
}

After all of those additions, I've got the following result:

As you can see, now errors at row level affect total outcome.

No Comments

Add a Comment