Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / Delete sales order usi...
Finance forum
Answered

Delete sales order using Odata / API

Posted on by 50

Hi
I am trying to delete a sales order using API DELETE method but I got the following error

{{baseURL}}/data/SalesOrderHeaders?$filter=SalesOrderNumber eq 'xx-xxx'

....

"message": "More than one resource was found when selecting for update.",
"type

  • Suggested answer
    Pete Alberts Profile Picture
    Pete Alberts 3,538 on at
    RE: Delete sales order using Odata / API

    I had the same experience a while ago.

    You are correct with your own answer. Even if your filtering assures that only a single record is retrieved (for example the filter you mentioned in your post), updating and deleting will not be allowed. The error message is lazy in my opinion. It is very generic. Maybe in the future it will say something like "Update not allowed with filtering. Rather use the EntityKey."

    For interest sake - if you create a custom entity with an EntityKey that is not unique and try to update a record that violates the key you will get the same error. For example create a DE of DirPartyTable and make the key DirPartyTable.Name, create two parties with the same name and then try to update one of them with the DE EntityKey.

  • Suggested answer
    Sumit Loya Profile Picture
    Sumit Loya 2,230 on at
    RE: Delete sales order using Odata / API

    Hi Ali, you are correct. There will be a possibility that same sales order number exists in more than one legal entity in D365 and the rows returned can be more than one.

  • Verified answer
    Ali J Profile Picture
    Ali J 50 on at
    RE: Delete sales order using Odata / API

    I just found the issue 
    I should use the following link for the delete request 


    {{baseURL}}/data/SalesOrderHeaders(SalesOrderNumber ='xxx',dataAreaId='xxx')

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,420 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,672 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans