Hi,
I am trying to use the standard Post & Print option that is on Sales Invoice Page. I am getting the following error:
Microsoft Dynamics NAV
The Sales Invoice Header does not exist. Identification fields and values: No.='XYZ1812RI0016'
OK
In Demo database its working fine, but in my database it is showing the above error.
The Sales Post and Print cdu is not customized.
On debugging it is getting stuck in the .Get function mentioned in the below code:
DocumentRecordRef.GETTABLE(HeaderDoc);
CASE DocumentRecordRef.NUMBER OF
DATABASE::"Sales Invoice Header":
BEGIN
SalesInvoiceHeader := HeaderDoc;
SalesInvoiceHeader.SETRANGE("No.",SalesInvoiceHeader."No.");
SalesInvoiceHeader.GET(SalesInvoiceHeader."No.");
SetCustomReportSelectionRange(
0
Answers
This is a modification.
weird code GET after setrange as doing pretty much same thing
Yes, my mistake!
The get I 'get'. Set the pointer after setting the filter.
|You should focus on the place from where PrintCustomReports is called as shown in de debugger.
message('%1',headerdoc.isrecord);
Is it an actual record in the Var?
It probably is.. sales invoice header, but give it a try.
SalesInvHeader."No." := "Last Posting No.";
This I do not trust, probably the reason
Try to add
SalesInvHeader.FIND;
IF Invoice THEN BEGIN
SalesInvHeader."No." := "Last Posting No.";
SalesInvHeader.SETRECFILTER;
CustomReportID := CustomReportSelection.PrintCustomReports(SalesInvHeader,SendReportAsEmail,FALSE);
IF CustomReportID = 0 THEN
PrintReport(ReportSelection.Usage::"S.Invoice");
END;
Thanks,
your custom code helped me in the Post and print,
But, the Report is not having any data related to the posted invoice, only the hardcoded part is printing and the default values.
In theory it is possible that NAV starts posting an invoice, fills the last posting no.
but has a rollback due to an error while posting.
The value for last posting no stays in the table, but the invoice does not exist.
I've 'misused' this field many times, so It could be that NAV was adjusted to fill this field differently.