Skip to main content

Hi Team,

I Have a very simple customization where inserting one line item programmatically on Order Qty Field Updated event.
Acumatica version : 21.208.0032

From screen level it is Inserting new line item and working as expected. While trying to create order from Postman facing the below error.

{
    "message""An error has occurred.",
    "exceptionMessage""Operation failed",
    "exceptionType""PX.Data.PXInvalidOperationException",
    "stackTrace""   at PX.Api.ContractBased.EntityService.Put(ISystemContract systemContract, String version, String name, EntityImpl entity, CbOperationContext operationContext, Boolean throwOnError)\r\n   at PX.Api.ContractBased.Soap.SoapFacadeBase.PutImpl(EntityImpl entity, Boolean throwOnValidationError)\r\n   at PX.Api.ContractBased.SystemContracts.V2.RestController.PutEntity(EntityImpl entity, String select, String filter, String expand, String custom)\r\n   at lambda_method(Closure , Object , Objectg] )\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_2.<GetExecutor>b__2(Object instance, Objectt] methodParameters)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()",
    "innerException": {
        "message""An error has occurred.",
        "exceptionMessage""The system failed to commit the Transactions row.",
        "exceptionType""PX.Data.PXException",
        "stackTrace""   at PX.Api.SyImportProcessor.SyStep.CommitChangesInt(Object itemToBypass, PXFilterRowx] targetConditions, PXFilterRow"] filtersForAction, SyImportRowResult importResult)\r\n   at PX.Api.SyImportProcessor.SyStep.CommitChanges(Object& itemToBypass, PXFilterRowc] targetConditions, PXFilterRow<] filtersForAction)\r\n   at PX.Api.SyImportProcessor.ExportTableHelper.ExportTable()"
    }
}

Here is the Code that i have implemented.

protected virtual void SOLine_OrderQty_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated BaseUpdatedevent)
        {
            if (BaseUpdatedevent != null)
            {
                BaseUpdatedevent(cache, e);
            }
            SOLine rows = (SOLine)e.Row;
            if ((Base.Document.Current.Status == "N" || Base.Document.Current.Status == "H" || Base.Document.Current.Status == "B" || Base.Document.Current.Status == "P") && rows.OrderQty > 0.0m)

            {
                if (rows.InventoryID != 10251)
                {

                    SOLine objv = (SOLine)Base.Transactions.Cache.Insert();
                    objv.InventoryID = 10251;
                    objv.IsFree = true;
                    objv.ManualDisc = true;
                    objv.OrderQty = 1;
                    Base.Transactions.Cache.Update(objv);
                    Base.Transactions.View.RequestRefresh();
                }

            }
        }
Postman Request :

{
    "OrderNbr": {
        "value""<NEW>"
    },
    "OrderType": {
        "value""SO"
    },
    "CustomerID": {
        "value""AACUSTOMER"
    },
    "Details": o
        {
            "InventoryID": {
                "value""PROD01"
            },
            "OrderQty": {
                "value""1.0000"
            }
        }
    ]
}



Thanks in Advance

Hi @praveenpo,

I wasn’t able to reproduce the issue in my local(in 23R109). Try an IIS reset or in a different instance, if the issue still persists, share the customization package or more details that might help to replicate the error.


hi @Vignesh Ponnusamy,

We are having this issue in the version 21.208 0032.


 


Hi @praveenpo,

Yes, I was able to reproduce the issue in 21.209 but couldn’t narrow down to the root cause of the issue.

I was able to get it working with the RowUpdated event, you could try it to see if that could help,

        protected void SOLine_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e, PXRowUpdated baseHandler)
{
baseHandler?.Invoke(cache, e);
var row = (SOLine)e.Row;
if ((Base.Document.Current.Status == "N" || Base.Document.Current.Status == "H" || Base.Document.Current.Status == "B" || Base.Document.Current.Status == "P") && row.OrderQty > 0.0m )
{
if (row.InventoryID != 311)
{

SOLine objv = new SOLine();
objv.InventoryID = 311;
objv.IsFree = true;
objv.ManualDisc = true;
objv.OrderQty = 1;
Base.Transactions.Cache.Update(objv);
Base.Transactions.View.RequestRefresh();
}
}

}

You can set a valid InventoryID that is available in your instance. Good Luck.!


hi @Vignesh Ponnusamy ,

Thanks for the suggestion, We will move to Row updated event  and verify.

 


Reply