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 :
Microsoft Dynamics AX (Archived)

deleting table records using x++

(0) ShareShare
ReportReport
Posted on by

Scenario: I want to delete all vendors ( deleted all transactions)

When i delete data from VendTable using x++ code data is present in related table.

Is there any way to traverse through all related table using x++ and delete.

*This post is locked for comments

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,075 Super User 2025 Season 2 on at

    Hi Ahmed,

    If the vendor did had transactions before, there can be still references in journals and dimension framework tables. In that case deletion is not possible in AX2012.

    But can you specify if the question is related to AX2012 or AX4? You used both versions in your tag which is very confusing.

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    There are Delete actions with restrictions on that table. Read the documentation https://msdn.microsoft.com/en-us/library/bb315018.aspx

    If there are transactions, you cannot/should not be able to delete the master data. If you have used doDelete, that is also a wrong approach, since the business logic implemented for correctly removing the vendors must be called. AX does traverse through the tables which have Delete actions, you do not have to write custom logic for this. The only change you need to do is that if there were customizations done to include vendor fields in your custom tables, but delete action logic was not adjusted, in which case you have to get it right then.

  • Community Member Profile Picture
    on at

    Hi Andre,

    I am able to delete from AP-> Vendors. But few vendors giving error as "transaction exist in ContactPerson table". When i delete that transaction I am able to delete vendors.

    But deleting multiple vendor is not happening. So i deleted from VendTable using x++.

    But when I do salesOrder posting it is fetching 1 vendor a/c which i have deleted and giving error....

  • Community Member Profile Picture
    on at

    @Andre

    Its 4.0 where I am trying currently.

  • Community Member Profile Picture
    on at

    @Kintera

    When i delete from AP-> vendors it will validate and delete (because of delete actions, it will delete from related table as well).

    I want to apply same mechanism using x++ code and delete all vendors.

  • André Arnaud de Calavon Profile Picture
    301,075 Super User 2025 Season 2 on at

    Hi Ahmed,

    I have corrected the tags for you. Can you explain more? You are now confusing me with also mentioning something about sales orders? What is the real issue? Do you have any detailed error messages?

  • Community Member Profile Picture
    on at

    @Andre

    let me make it simple...i want to delete from vend table as well as all related table contents using x++.

  • Mea_ Profile Picture
    60,284 on at

    Hi Ahmed,

    What stops you from manually specifying all related tables and  delete records from them ?

    Because if delete actions does not work for you it is the only way I can see.

  • Community Member Profile Picture
    on at

    @Miroshnikov

    When I go to table mentioned in delete actions and check it also has many tables under delete actions, again under that table there are many table listed under delete action.

    then it will be a lengthy process....

  • Mea_ Profile Picture
    60,284 on at

    No one says that it would be easy.

    A lot of effort was done to prevent users from deleting this info from the system. I don't think that you should ever try because if vendor has transactions it means that he sold something to you so deleting them from the system as some kind of a fraud and definitely is not supported out of the box.

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans