web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

unable to patch SalesOrderLines to all sales order in dynamics 365 F&O using postman

(1) ShareShare
ReportReport
Posted on by 15
I'm able to create lines using postman for salesorder lines but not able to PATCH those lines created.
FYI: we don't have salesorderlinesId entity in dynamics hence using InventoryLotId
For posting lines::
URL: https://{{dynamics-url}}/Data/SalesOrderLines (using these details I'm able to post lines and getting success response)
Body
"ItemNumber": "",
"SalesOrderNumber": ""} 
 
For patching Lines::
URL: https://{{dynamics-url}}/Data/SalesOrderLinesV3?$filter=((SalesOrderNumber eq 'XXX') and (dataAreaId eq 'XXX') and (ItemNumber eq 'XXX')) [using this url and body getting error response and unable to patch the lines]
Body
"InventoryLotId": "",
   "OrderedSalesQuantity": }
detailed error while patching: 
{
    "error": {
        "code": "",
        "message": "An error has occurred.",
        "innererror": {
            "message": "More than one resource was found when selecting for update.",
            "type": "Microsoft.Dynamics.Platform.Integration.Services.OData.ODataArgumentException",
            "stacktrace": "   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.UpdateManager.GetEntityForUpdate(IQueryable query, EntityType entityType)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataController.GetChangeInfoWithConcurrencyCheck(RequestEntityInfo requestEntityInfo)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataController.Patch()\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_1.<GetExecutor>b__0(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.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__17`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.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.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__17`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.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.Tracing.Tracers.HttpControllerTracer.<ExecuteAsyncCore>d__10.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.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__17`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.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()"
        }
    }
}
I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at
    The error message is right - an ItemId isn't a unique identification of a line in an order. Also, you shouldn't be using a filter at all.
     
    Instead, refer to the entity key in the format like this: /data/Entity1(Field1='Value1',Field2='Value2').

    The entity key of SalesOrderLineV2Entity (which is currently the entity with the public name SalesOrderLine) is InventoryLotId (plus DataAreaId).
     
    (Moved from D365 general forum to the Finance forum, because it's clearly about F&O and not about D365 in general.)
  • CU27081722-2 Profile Picture
    15 on at
    as suggested I used this URL: 
    https://{{dynamics-url}}/Data/SalesOrderLines(SalesOrderNumber='12345',InventoryLotId='XX-12345')
     
    with body:  
    {
       "OrderedSalesQuantity": 15}
     
    I got 404 Not found error with 
    {
        "Message": "No HTTP resource was found that matches the request URI 'https://uat.sandbox.operations.dynamics.com/Data/SalesOrderLines(SalesOrderNumber='12345',InventoryLotId='xx-12345')'. No route data was found for this request."
    }
  • Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at
    Please look at the entity (SalesOrderLineV2Entity). You'll see that I what I told you was correct: there is no SalesOrderNumber in the entity key. And there is another thing you missed in my reply: that you need to include DataAreaId.

    Therefore it should be something like /data/SalesOrderLines(InventoryLotId='XX-12345',DataAreaId='XXX').
  • CU27081722-2 Profile Picture
    15 on at
    Hi Martin,
     
    Thanks for the response, now while trying to PATCH getting 400 BAD REQUEST
    URL: https://{{dynamics-url}}/Data/SalesOrderLines(InventoryLotId='XX-1234',dataAreaId='XXXX')
    BODY: 
     { "OrderedSalesQuantity": 15}
    RESPONSE:
    {
        "error": {
            "code": "",
            "message": "An error has occurred.",
            "innererror": {
                "message": "Write validation failed for table row of type 'SalesOrderLineV2Entity'. Infolog: Warning: The sales order line entity does not support updates of sales orders which are associated with a retail channel..",
                "type": "Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataValidateWriteException",
                "stacktrace": "   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.UpdateProcessor.UpdateEntity_Save(ChangeOperationContext context, ChangeInfo changeInfo)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.ChangeInfo.ExecuteActionsInCompanyContext(IEnumerable`1 actionList, ChangeOperationContext operationContext)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.ChangeInfo.TrySave(ChangeOperationContext operationContext)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.UpdateManager.SaveChanges()\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataDelegatingHandler.<SaveChangesAsync>d__2.MoveNext()"
            }
        }
    }
  • Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at
    Good, now the URL is correct and the update reached F&O. To learn what happened there, you must read the error message, not just the HTTP code. It says: "The sales order line entity does not support updates of sales orders which are associated with a retail channel".
  • CU27081722-2 Profile Picture
    15 on at
    Hello Martin
    Indeed, I did read the error message and attempted to include the error code and error response. I'm attempting to comprehend this situation. Since updating the SalesOrderLines is a prerequisite, I need some assistance as I don't have much experience with Dynamics. Please let me know if there is a solution to update the lines for the circumstance that was described.
    Although it appears that there is a certain setup in our environment that is preventing the lines from being updated, we want to make sure that this is the case. Any support would be much valued.
  • Suggested answer
    Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at
    I'm not very familiar with Retail, but I'm sure that Microsoft implemented this validation for a reason, not just that they were bored. I guess that that the source of truth is the retail channel, e.g. an e-shop, and updating the order in F&O only would lead to data inconsistency and a possible data loss.
     
    Are you 100% sure that you want to update orders coming from retail channels? Your description so far suggested that you didn't consider this scenario at all, not that you considered it and decided that it's the right thing to do. And if you don't expect any data from retail channels, don't you just have wrong data in your database?
     
    If you're sure that you want to update orders from retail channels and it's safe in your case (so you don't cause any data corruption for you or your client), you'll have to change the logic inside F&O. And because I don't see any meaningful way how to do it via an extension, you'll need a custom data entity.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 449 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 422 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans