Not delete sales order

gemini_shooter
Member Posts: 149
Hello Guys,
I am trying to modify the code 80 to prevent sales order from getting deleted.
I have able to keep the sales line but I am unable to keep the sales header.
I commented this part of the code for sales header but I am not sure if it is the right piece of code. Can someone please help
DocDim.RESET;
DocDim.SETRANGE("Table ID",DATABASE::"Sales Header");
DocDim.SETRANGE("Document Type","Document Type");
DocDim.SETRANGE("Document No.","No.");
// DocDim.DELETEALL;
DocDim.SETRANGE("Table ID",DATABASE::"Sales Line");
// DocDim.DELETEALL;
ApprovalMgt.DeleteApprovalEntry(DATABASE::"Sales Header","Document Type","No.");
IF HASLINKS THEN DELETELINKS;
DELETE;
ReserveSalesLine.DeleteInvoiceSpecFromHeader(SalesHeader);
IF SalesLine.FINDFIRST THEN REPEAT
IF SalesLine.HASLINKS THEN
;
// SalesLine.DELETELINKS;
UNTIL SalesLine.NEXT = 0;
// SalesLine.DELETEALL;
DeleteItemChargeAssgnt;
SalesCommentLine.SETRANGE("Document Type","Document Type");
SalesCommentLine.SETRANGE("No.","No.");
IF NOT SalesCommentLine.ISEMPTY THEN
// SalesCommentLine.DELETEALL;
WhseRqst.SETCURRENTKEY("Source Type","Source Subtype","Source No.");
WhseRqst.SETRANGE("Source Type",DATABASE::"Sales Line");
WhseRqst.SETRANGE("Source Subtype","Document Type");
WhseRqst.SETRANGE("Source No.","No.");
IF NOT WhseRqst.ISEMPTY THEN
I am trying to modify the code 80 to prevent sales order from getting deleted.
I have able to keep the sales line but I am unable to keep the sales header.
I commented this part of the code for sales header but I am not sure if it is the right piece of code. Can someone please help
DocDim.RESET;
DocDim.SETRANGE("Table ID",DATABASE::"Sales Header");
DocDim.SETRANGE("Document Type","Document Type");
DocDim.SETRANGE("Document No.","No.");
// DocDim.DELETEALL;
DocDim.SETRANGE("Table ID",DATABASE::"Sales Line");
// DocDim.DELETEALL;
ApprovalMgt.DeleteApprovalEntry(DATABASE::"Sales Header","Document Type","No.");
IF HASLINKS THEN DELETELINKS;
DELETE;
ReserveSalesLine.DeleteInvoiceSpecFromHeader(SalesHeader);
IF SalesLine.FINDFIRST THEN REPEAT
IF SalesLine.HASLINKS THEN
;
// SalesLine.DELETELINKS;
UNTIL SalesLine.NEXT = 0;
// SalesLine.DELETEALL;
DeleteItemChargeAssgnt;
SalesCommentLine.SETRANGE("Document Type","Document Type");
SalesCommentLine.SETRANGE("No.","No.");
IF NOT SalesCommentLine.ISEMPTY THEN
// SalesCommentLine.DELETEALL;
WhseRqst.SETCURRENTKEY("Source Type","Source Subtype","Source No.");
WhseRqst.SETRANGE("Source Type",DATABASE::"Sales Line");
WhseRqst.SETRANGE("Source Subtype","Document Type");
WhseRqst.SETRANGE("Source No.","No.");
IF NOT WhseRqst.ISEMPTY THEN
0
Comments
-
Hi,
Look for the variable EverythingInvoiced.
Your records will only be deleted if this variable is true.
Regards,Reijer Molenaar
Object Manager0 -
Or you could change your process so that you don't invoice from the order, but create the invoice manually then use copy document etc. This doesn't delete the sales order.0
-
I am not sure of NAV 2009 but in earlier versions copy document does not update the remaining quantity on the original sales order which is correct also. This creates problem in calculating pending sales order.
We can post shipment from sales order and then use Sales invoice function :get shipment lines and then invoice.CA Sandeep Singla
http://ssdynamics.co.in0 -
gemini_shooter wrote:Hello Guys,
I am trying to modify the code 80 to prevent sales order from getting deleted.
I have able to keep the sales line but I am unable to keep the sales header.
This can have serious performance issues in a large database, or one where many users are entering orders. Be careful that you now what you are doing before you do this.
Look at the order archive function first.David Singleton0 -
One more option: Or u can receive using Sales Order and Invoice using Get Receipt Lines. Order will stay there.Kapil Khanna0
-
I strongly suggest that you archive the Sales order and allow it to get deleted.
Your MRP will be screwed up, Users will try to modify and repost old sales order,
Performance as mentioned will go down the drain.
You will not be able to upgrade your DB.
Create separate tables and keep the data in separate table. This is the safest option.0 -
ara3n wrote:I strongly suggest that you archive the Sales order and allow it to get deleted.
Your MRP will be screwed up, Users will try to modify and repost old sales order,
Performance as mentioned will go down the drain.
You will not be able to upgrade your DB.
Create separate tables and keep the data in separate table. This is the safest option.
Been there thanks to the previous developers of a project I took over. So take David Singleton's
and ara3n's advise. You'll be thankful you did!!!0 -
Thanks guys... this is just a test and not in a live setup.
All I want to do is to prevent the Sales header from being deleted.
Can anyone tell me where in code or how does this happen.0 -
CU 80 has a
with salesheader do begin
end
So search for just DELETE;
somebody allready mentioned to look the section that has has everything invoiced.0 -
I commented this part of the code. The sales lines do not get deleted but the sales header still does. Am I still missing something
DocDim.RESET;
DocDim.SETRANGE("Table ID",DATABASE::"Sales Header");
DocDim.SETRANGE("Document Type","Document Type");
DocDim.SETRANGE("Document No.","No.");
// DocDim.DELETEALL;
DocDim.SETRANGE("Table ID",DATABASE::"Sales Line");
// DocDim.DELETEALL;0 -
Keep looking down a couple of lines and you will see
DELETE;
THIS IS THE LINE.0 -
Old topic, but as I met the same problem: no, it is not necessarily a bad practice as long as they are regularly deleted by using Report 299. For example every quarter or year.
If you have a lot of reports or complicated ones that involve orders, also fully invoiced one - e.g. I send out automatically to salespeople every day a report showing the last 3 months of sales orders, showing their status, shipped, invoiced, so they can check how things went - it is easier to turn off automatic deletion and simply run this report as a part of a regular maintenance.
And yes, the elegant solution is something along the lines of
IF SalesSetup."Do not delete invoiced orders" THEN
EverythingInvoiced := FALSE;0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions