Notifications
Announcements
No record found.
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
DELETEFROM [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
DELETEFROM [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
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.
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!
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.
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
HoangNam 7