web
You’re offline. This is a read only version of the page.
close
Skip to main content
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)
  • Community Member Profile Picture
    on at
    RE: delete_from validate deletes

    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.

  • Community Member Profile Picture
    on at
    RE: delete_from validate deletes

    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.

  • Verified answer
    Andrew Xu Profile Picture
    3,877 on at
    RE: delete_from validate deletes

    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
    RE: delete_from validate deletes

    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.

  • Andrew Xu Profile Picture
    3,877 on at
    RE: delete_from validate deletes

    You can overwrite the validateDelete method to force it to return 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#1
Guy Terry Profile Picture

Guy Terry 2 Moderator

#1
Rahul Shah Profile Picture

Rahul Shah 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans