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)

delete_from validate deletes

(0) ShareShare
ReportReport
Posted on by

Suppose I want to delete a lot of records from DirPartyTable (or any table where you can run validateDelete() or something similar).  It would seem that using a delete_from statement would be the way to go.  However if one of the records cannot be deleted (i.e., validateDelete() returns false) it looks like the entire statement fails and none of the records are deleted.

Is there a way to run a delete_from statement and skip the records where validateDelete is false?  I tried adding validateDelete to the query but then the job wouldn't even compile.

*This post is locked for comments

I have the same question (0)
  • Andrew Xu Profile Picture
    3,877 on at

    You can overwrite the validateDelete method to force it to return true.

  • Community Member Profile Picture
    on at

    But I want the validateDelete to run.  I've done my best to make sure I'm not deleting records that shouldn't be deleted but it's nice to have the backup that validateDelete provides.

  • Verified answer
    Andrew Xu Profile Picture
    3,877 on at

    1. Add a temporary NoYes field in the table, let's say field 'CanBeDeleted'.

    2. Call validateDelete to update the value of field 'CanBeDeleted'. If true, set the value to Yes, and if false, set the value to No.

    3. Run delete_from DirPartyTable where DirPartyTable .CanBeDeleted == NoYes::Yes.

    4. Delete the field 'CanBeDeleted'.

  • Community Member Profile Picture
    on at

    I hadn't thought about using a temporary column.  It's not the worst solution in the world.  I think I'll give it a try.

  • Community Member Profile Picture
    on at

    Wouldn't step 2 negate the benefits of using delete_from?

    If you are already going record by record to define the value of the extra column, just do the delete record by record.

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