0
votes

I am trying to add a new sales order, with detail rows, to my Acumatica system using the a custom endpoint I created at:

https://172.16.8.65/entity/ASG_INTEGRATION/6.00.001/SalesOrder

This is the JSON body I am sending in Postman:

{
    "OrderType": {  "value": "SO"     },
    "CustomerID": { "value": "6362212668"   },
    "Details": 
    [
        {
            "Account": {"value": "4040"            },
            "Branch": {"value": "00"                },
            "InventoryID": { "value": "33964"            },
            "OrderQty": { "value": 1.000000     }
        }
    ]
}

The reason I had to create the custom End Point was because the "Branch" field that I have on my detail sales order item must be included, and the Default end point did not have the Branch field in its populated fields. (Thanks to this SO Question for pointing the way to that wrinkle!)

But now I get the following error (which does not tell me where to look for the error -- at least that I can see...):

{
    "message": "An error has occurred.",
    "exceptionMessage": "PX.Data.PXException: Error: The system failed to commit the CurrentDocument row.\r\n   at PX.Api.SyImportProcessor.SyStep.a(Object A_0, PXFilterRow[] A_1, PXFilterRow[] A_2) in C:\\Bld2\\AC-FULL2019R113-JOB1\\Sources\\NetTools\\PX.Data\\Api\\Export\\SyImport\\ImportProcessor.cs:line 3638\r\n   at PX.Api.SyImportProcessor.ExportTableHelper.ExportTable() in C:\\Bld2\\AC-FULL2019R113-JOB1\\Sources\\NetTools\\PX.Data\\Api\\Export\\SyImport\\ImportProcessor.cs:line 1171",
    "exceptionType": "PX.Api.ContractBased.OutcomeEntityHasErrorsException",
    "stackTrace": "   at System.Monads.ArgumentCheck.CheckNull[TSource](TSource source, Func`1 exceptionSource)\r\n   at PX.Api.ContractBased.EntityService.GetOperationResult(EntityImpl entity, EntityExportContextBuilder entityExportContextBuilder, PXSYTable exportedKeys, List`1 errors) in C:\\Bld2\\AC-FULL2019R113-JOB1\\Sources\\NetTools\\PX.Api.ContractBased\\EntityService.cs:line 480\r\n   at PX.Api.ContractBased.EntityService.Put(ISystemContract systemContract, String version, String name, EntityImpl entity, CbOperationContext operationContext) in C:\\Bld2\\AC-FULL2019R113-JOB1\\Sources\\NetTools\\PX.Api.ContractBased\\EntityService.cs:line 474\r\n   at PX.Api.ContractBased.Soap.SoapFacadeBase.PutImpl(EntityImpl entity) in C:\\Bld2\\AC-FULL2019R113-JOB1\\Sources\\NetTools\\PX.Api.ContractBased\\Soap\\SoapFacadeBase.cs:line 117\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] 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__0.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__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.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>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.<ExecuteActionFilterAsyncCore>d__0.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__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.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>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.<ExecuteActionFilterAsyncCore>d__0.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__2.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__2.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__0.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__0.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__1.MoveNext()"
}

Any idea where to go next in my debugging?

[Edit:Adding screenshots to address Fernando's question]

There are 2 possible branches, both named the same, and you cannot add both of them to an entity. Financial Settings Popup

And this is in Document Details Document Settings

Which one should I use? How can I know??? When I replicate what @Fernando shows (I assume using the Document Details "Branch"), I get a "Branch cannot be Empty" error:

Branch Cannot Be Empty

1
which Acumatica version are you using? Which endpoint (and version) was extended?Fernando
@Fernando - I extended "Default" version 6.00.001. Acumatica version 2019 R1. (Updated question with screenshot)MarkJoel60
Are there any customizations in that page? It works correctly on my end. I followed these steps: 1-Extended the endpoint and added the Branch and Account in the Details entity. 2-Made the PUT request as shown here: imgur.com/a/J3cTI5wFernando
Note: the title of your post should make reference to Sales Order, not Service OrderFernando
@Fernando - 1. Which "Branch" did you add? (I saw two of them). 2. There are some customizations to the page -- does that affect how the Endpoint works? (And I changed the title. Thanks!)MarkJoel60

1 Answers

0
votes

OK, my conversation with Fernando was helpful. Here's what I discovered, and here's what worked:

The fact that there are two different ways of selecting "Branch" in the Fields is significant.

One shows up in the "Document Details" PopUp Document Details Fields

And one shows up in the Financial Settings -> Financial Information PopUp: Financial Settings Field

As it turns out BOTH are needed. But they can't both belong to the SalesOrder Entity -- that's not allowed.

So, I extended the SalesOrder Entity with the Financial Settings "Branch"

Sales Order Entity Extension

And, I extended the SalesOrderDetail Entity with the DocumentDetails "Branch"

enter image description here

And then I could do this and it was accepted:

{
        "CustomerID": { "value": "76758" },
        "OrderType": {  "value": "SO"      },
        "Branch": {  "value": "00"  },
        "Details": 
        [
            {
                "Account": {  "value": "4040"   },
                "Branch": {  "value": "00"  },
                "InventoryID": {  "value": "33964"},
                "OrderQty": {  "value": 1.000000  }
            }
        ]
    }

Setting the branch in only one of those places would not create an accepted Sales Order record. So this worked and I have a new Sales Order, with a detail line in it.

I cannot remember now, because I tried so many different things, but, I believe that in the 18.200.001 version of SalesOrder, the Branch field already exists in the SalesOrder Detail, but not in SalesOrder. And in the 6.00.001 version it doesn't exist in either. I'm not sure, but I think that is how it is. In case anyone stumbles across this and is using a different version...