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

  • Mea_ Profile Picture
    60,278 on at
    RE: deleting table records using x++

    As I already told you there is no silver bullet to delete all related records from AX even using delete action so you have to delete them using your own custom code.

  • Community Member Profile Picture
    on at
    RE: deleting table records using x++

    I have done like that...but i have observed that in related table data related to that vendors is present. For example in ContactPerson table.

  • Mea_ Profile Picture
    60,278 on at
    RE: deleting table records using x++

    if you don't have transaction just do

    while select forupdate vendTable

    {

       vendTable.doDelete();

    }

  • Community Member Profile Picture
    on at
    RE: deleting table records using x++

    @Miroshnikov

    But in this scenario what I am doing is creating a new company by duplicating a company. And by keeping the setup. I have deleted all transactions. I wanted to delete Vendors.

  • Mea_ Profile Picture
    60,278 on at
    RE: deleting table records using x++

    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.

  • Community Member Profile Picture
    on at
    RE: deleting table records using x++

    @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,278 on at
    RE: deleting table records using x++

    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
    RE: deleting table records using x++

    @Andre

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

  • André Arnaud de Calavon Profile Picture
    295,853 Super User 2025 Season 1 on at
    RE: deleting table records using x++

    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
    RE: deleting table records using x++

    @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.

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

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Kempeth Profile Picture

Kempeth 4

#1
Andy Adamak Profile Picture

Andy Adamak 4

#1
Community Member Profile Picture

Community Member 4

Featured topics

Product updates

Dynamics 365 release plans