Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

InventTable delete action not working by code

Posted on by 30

Hello everybody,

I have a record on InvenTable, which is related to another record in InventJournalTrans.

In other words I have created an item and inserted it into an adjustment journal, which means there are all related record in InventTrans etc...

The issue I faced is the following:

If I try to delete the item from Released product form, standard delete action (Restricted) works properly, so i get the error "<table> cannot be deleted while dependent <table> exist..."

If I try to delete the item by code instead:

ttsBegin;
select forUpdate InventTable
where InventTable.ItemId == "xxx";
InventTable.delete();
ttsCommit;

the check is not performed and the record is deleted anyway.

I wonder why because I am using delete() method and not doDelete() method.

Has anyone faced this problem before?

Thanks

G

*This post is locked for comments

  • Verified answer
    Blue Wang Profile Picture
    Blue Wang on at
    RE: InventTable delete action not working by code

    Hi Giacomo,

    Try this:

    while select forUpdate inventTable where inventTable.ItemId == "xxx"
        {
            if(inventTable.validateDelete())
               {
                   ttsBegin;
                   InventTable.delete();
                   ttsCommit;
               }
        }


    I hope it will help you.

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: InventTable delete action not working by code

    In code you need to call validateDelete yourself and then call delete only if it returned true.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans