Hello everybody!!
I need to change the report 499 for to archive purchase orders before deleting them (cause the invoice is posted from invoices and not from orders, and so is not archived by default)
in OnAfterGetRecord () I added these lines:
PurchHeader.SETRANGE ("Document Type", "Document Type");
PurchHeader.SETRANGE ("No.", "No.");
ArchiveManagement.ArchivePurchDocument (PurchHeader);
ArchiveManagement is the codeunit used in Orders/Functions/Archive Document
but does not archive, only does delete
Answers
Kanika,
just add a: before calling ArchivePurchDocument procedure.
Federico
MBS Specialist since NAV 2.0
My experiences on Linkedin
PurchHeader.SETRANGE ("Document Type", "Document Type");
PurchHeader.SETRANGE ("No.", "No.");
PurchHeader.FINDSET;
ArchiveManagement.ArchivePurchDocument (PurchHeader);
but this still does not work
Kanika,
where did you put this code?
Federico
MBS Specialist since NAV 2.0
My experiences on Linkedin
Window.UPDATE(1,"No.");
AllLinesDeleted := TRUE;
DocDim.RESET;
DocDim.SETRANGE("Document Type","Document Type");
DocDim.SETRANGE("Document No.","No.");
ItemChargeAssgntPurch.RESET;
ItemChargeAssgntPurch.SETRANGE("Document Type","Document Type");
ItemChargeAssgntPurch.SETRANGE("Document No.","No.");
PurchLine.RESET;
PurchLine.SETRANGE("Document Type","Document Type");
PurchLine.SETRANGE("Document No.","No.");
PurchLine.SETFILTER("Quantity Invoiced",'<>0');
IF PurchLine.FIND('-') THEN BEGIN
PurchLine.SETRANGE("Quantity Invoiced");
PurchLine.SETFILTER("Outstanding Quantity",'<>0');
IF NOT PurchLine.FIND('-') THEN BEGIN
PurchLine.SETRANGE("Outstanding Quantity");
PurchLine.SETFILTER("Qty. Rcd. Not Invoiced",'<>0');
IF NOT PurchLine.FIND('-') THEN BEGIN
PurchLine.LOCKTABLE;
IF NOT PurchLine.FIND('-') THEN BEGIN
PurchLine.SETRANGE("Qty. Rcd. Not Invoiced");
DocDim.SETRANGE("Table ID",DATABASE::"Purchase Line");
IF PurchLine.FIND('-') THEN
REPEAT
PurchLine.CALCFIELDS("Qty. Assigned");
IF ((PurchLine."Qty. Assigned" = PurchLine."Quantity Invoiced") AND
(PurchLine."Qty. Assigned" <> 0)) OR
(PurchLine.Type <> PurchLine.Type::"Charge (Item)")
THEN BEGIN
DocDim.SETRANGE("Line No.",PurchLine."Line No.");
PurchHeader.SETRANGE("Document Type","Document Type");
PurchHeader.SETRANGE("No.","No.");
PurchHeader.FINDSET;
ArchiveManagement.ArchivePurchDocument(PurchHeader);
DocDim.DELETEALL;
IF PurchLine.Type = PurchLine.Type::"Charge (Item)" THEN BEGIN
ItemChargeAssgntPurch.SETRANGE("Document Line No.",PurchLine."Line No.");
ItemChargeAssgntPurch.DELETEALL;
END;
IF PurchLine.HASLINKS THEN
PurchLine.DELETELINKS;
PurchLine.DELETE;
END ELSE
AllLinesDeleted := FALSE;
UNTIL PurchLine.NEXT = 0;
IF AllLinesDeleted THEN BEGIN
PurchPost.DeleteHeader(
"Purchase Header",PurchRcptHeader,PurchInvHeader,PurchCrMemoHeader,
ReturnShptHeader,PrepmtPurchInvHeader,PrepmtPurchCrMemoHeader);
ReservePurchLine.DeleteInvoiceSpecFromHeader("Purchase Header");
PurchCommentLine.SETRANGE("Document Type","Document Type");
PurchCommentLine.SETRANGE("No.","No.");
PurchCommentLine.DELETEALL;
DocDim.SETRANGE("Table ID",DATABASE::"Purchase Header");
DocDim.SETRANGE("Line No.",0);
DocDim.DELETEALL;
WhseRequest.SETRANGE("Source Type",DATABASE::"Purchase Line");
WhseRequest.SETRANGE("Source Subtype","Document Type");
WhseRequest.SETRANGE("Source No.","No.");
WhseRequest.DELETEALL(TRUE);
IF HASLINKS THEN
DELETELINKS;
DELETE;
END;
COMMIT;
END;
END;
END;
END;
Try to put the code after
Window.UPDATE(1,"No.");
Federico
MBS Specialist since NAV 2.0
My experiences on Linkedin
Could it be the codeunit?
if there were an ARCHIVEALL like exists an DELETEALL.............................
Have you modified the codeunit too?
Try to call directly:
instead of
Lol... this has to be written in a book!
DELETEALL is a Nav internal function.
ARCHIVEALL does not exist!
Federico
MBS Specialist since NAV 2.0
My experiences on Linkedin
was in the codeunit
had effectively changed to avoid having to confirm each record
now work perfectly
really thank you very much
Just restore the confirm (if you need it per each order).
It was asked for each line because you previously put the code into the line loop!
You're welcome.
Federico
MBS Specialist since NAV 2.0
My experiences on Linkedin