Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

items table records that are used in other tables are being deleted when i try to delete the records that are not used.i want to delete only those records which are not used.

Posted on by 2

Hello All

I have created a table called MODEL and I have created a page called MODEL VERSION LIST and MODEL VERSION CARD whose source table are ITEM table.I have also created a page called MAKE LIST and MAKE MODEL whose source table are MODEL table.The field Model Code are used in ITEM and MODEL table as well.

What I am trying to do is, I am trying to delete the item record from the MODEL VERSION LIST that are not used in ITEM table.

I have written the code on MODEL table in OnDelete trigger as

item.setrange("model code","code");

if item.findfirst then begin

ERROR('The model code is in use.It cannot be deleted from the item table');

end;

But the code does not seem to be working at all.

*This post is locked for comments

  • Sulav Thapaliya Profile Picture
    Sulav Thapaliya 2 on at
    RE: items table records that are used in other tables are being deleted when i try to delete the records that are not used.i want to delete only those records which are not used.

    The problem has been solved.

    Thank you for your concern

  • Sulav Thapaliya Profile Picture
    Sulav Thapaliya 2 on at
    RE: items table records that are used in other tables are being deleted when i try to delete the records that are not used.i want to delete only those records which are not used.

    The problem has been solved now.

    Thank You For Your Concern.

  • Verified answer
    keoma Profile Picture
    keoma 32,675 on at
    RE: items table records that are used in other tables are being deleted when i try to delete the records that are not used.i want to delete only those records which are not used.

    when you remove a model record, do you call delete or delete(true)? the ondelete trigger is only called, when delete(true) is used.

  • mmv Profile Picture
    mmv 11,465 on at
    RE: items table records that are used in other tables are being deleted when i try to delete the records that are not used.i want to delete only those records which are not used.

    Hi,

    Where the above code is written?  Table or Page?

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans