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
0
Comments
Look for the variable EverythingInvoiced.
Your records will only be deleted if this variable is true.
Regards,
Object Manager
We can post shipment from sales order and then use Sales invoice function :get shipment lines and then invoice.
http://ssdynamics.co.in
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.
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.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
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!!!
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.
with salesheader do begin
end
So search for just DELETE;
somebody allready mentioned to look the section that has has everything invoiced.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
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;
DELETE;
THIS IS THE LINE.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
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;