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 NAV (Archived)

Delete All Sales Quotes within Date Range

(0) ShareShare
ReportReport
Posted on by

I've recently been wanting to clear down thousands of sales quotes in our NAV 2015 installation, but from reading up there is not a built-in routine to do this.

Initially I saw some articles surrounding modifying the Delete Archive Sales Quote versions report but I'm not too knowledgeable in that area.

Instead I thought about doing it via a couple of SQL Queries - I'm wondering if this is fine to do or would this cause problems?

1st Query - Delete from Sales Header

DELETE
FROM [Sales Header]
WHERE [Document Type] = '0' AND [Document Date] < '12/31/2017'

This worked perfectly and cleared down the Sales Quotes in the RTC

2nd Query - Delete Orphaned Sales Lines

DELETE
FROM [Sales Line]
WHERE NOT EXISTS (SELECT No_ FROM [Sales Header]
WHERE [Sales Line].[Document No_] = [Sales Header].[No_])

Any help would be much appreciated.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    Why not directly using C/AL?

    A simple codeunit that loops through Sales Header table, apply filters and triggers a DELETE(TRUE) operation. This will automatically deletes the lines and all the other related tables.

    However, the SQL code works. If you want to be more clean, you should also delete Sales Comment Line table.

  • Community Member Profile Picture
    on at

    Hi Stefano, Thanks for your reply - unfortunately my knowledge on C/AL isn't that great so I wouldn't be sure where to start. Do you know where I could learn to do this? Would I need a specific license for developing a codeunit?

    Thanks!

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    You can create a new codeunit with a free ID (for example 50000) and in the OnRun trigger write this code:

    MyDate := DMY2DATE(31,12,2017);

    SalesHeader.SETRANGE("Document Type",SalesHeader."Document Type"::Quote);

    SalesHeader.SETFILTER("Document Date",'..%1',MyDate);

    SalesHeader.DELETEALL(TRUE);

    where:

    SalesHeader DataType: Record Subtype: Sales Header

    MyDate DataType: Date

    Then just run that codeunit.

  • Suggested answer
    Suresh Kulla Profile Picture
    50,245 Super User 2025 Season 2 on at

    You could import this tool and delete the records from table 36 and 37

    www.olofsimren.com/record-deletion-tool-for-dynamics-nav-2015

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 NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans