The Sales Header does not exist

Nagaboona
Member Posts: 33
Good day,
I have a job queue that would automatically generate invoices and receipts for your customers. Unfortunately it is now giving errors:
The Sales Header does not exist. Identification fields and values: Document Type='Invoice',No.='INV-00555459'
and no more invoices or receipts are being generated.
Could someone please assist on how to sort this out?
Thanks,
Nagab
I have a job queue that would automatically generate invoices and receipts for your customers. Unfortunately it is now giving errors:
The Sales Header does not exist. Identification fields and values: Document Type='Invoice',No.='INV-00555459'
and no more invoices or receipts are being generated.
Could someone please assist on how to sort this out?
Thanks,
Nagab
0
Answers
-
You're trying to GET, MODIFY, or RENAME a Sales Header with Type = Invoice, and No. = INV-00555459.
It's impossible to figure out more details without reviewing the code. Can you share it in this thread?0 -
Hi Phogue,
Thanks a lot for your response.
I have a job queue that automatically generate invoices and receipts for our customers. However, for some reasons it has stopped working with the mentioned error message as in the attachment.
Regards,
Nagab0 -
-
Hi Nagaboona,
If you wish for us to help you, please share the contents of codeunit 50001
0 -
Hello Phogue,
Thanks for your concern, I shall share the codeunit 50001 content as below. Sorry I failed to attached it.
Thanks in advance,
Fredrick.0 -
Documentation()
OnRun()
GenerateInvoice();
GenerateReceipt();
DeleteSuccessJobQueueLogEntry();
GenerateInvoice()
rRec.RESET;
rRec.COPYFILTERS(Rec);
rRec.SETFILTER("Invoice Created?",FORMAT(FALSE));
rRec.SETFILTER(rRec."Receipt Created?",FORMAT(FALSE));
rRec.SETFILTER(rRec."Bill Status",'2');
rRec.SETFILTER(rRec."Zone Code",'<>%1',0);
rRec.SETRANGE(rRec.Status,rRec.Status::Permanent);
IF rRec.FINDFIRST THEN
BEGIN
REPEAT
//Navision customer
Cust.SETRANGE("No.",rRec."Customer No.");
IF Cust.FINDFIRST THEN
BEGIN
//Get the document number to be used to generate the Invoice
SalesRecSetup.RESET;
IF SalesRecSetup.GET(SalesRecSetup."Invoice Nos.") THEN
BEGIN
InvNo:=SalesRecSetup."Invoice Nos.";
END;
SalesH.RESET;
SalesH.SETRANGE("Document Type",SalesH."Document Type"::Invoice);
SalesH.SETRANGE("No. Series",InvNo);
IF SalesH.FINDLAST THEN
BEGIN
DocumentNo:=INCSTR(SalesH."No.");
END
ELSE
BEGIN
DocumentNo:=NoSeriesMgt.GetNextNo(InvNo,0D,FALSE);
END;
//Insert Header
SalesH.RESET;
SalesH.INIT;
SalesH."No.":=DocumentNo;
SalesH.VALIDATE("No.");
SalesH."No. Series":=InvNo;
SalesH."Document Type":=SalesH."Document Type"::Invoice;
SalesH."Control Number":=rRec."Bill Control Number";
SalesH."Sell-to Customer No.":=rRec."Customer No.";
SalesH.VALIDATE("Sell-to Customer No.");
{SalesH."Shortcut Dimension 1 Code":=ActCode;
SalesH.VALIDATE("Shortcut Dimension 1 Code");
SalesH."Shortcut Dimension 2 Code":=BLcode;
SalesH.VALIDATE("Shortcut Dimension 2 Code");}
SalesH.INSERT;
//Insert Lines
BillItems.RESET;
BillItems.SETRANGE("Bill ID",rRec.Bill_ID);
IF BillItems.FINDFIRST THEN
REPEAT
IF BillItems.FINDLAST THEN LineNo:=LineNo+1000 ELSE LineNo:=1000;
SalesL.RESET;
SalesL.INIT;
SalesL."Document Type":=SalesL."Document Type"::Invoice;
SalesL."Document No.":=DocumentNo;
SalesL."Line No.":=LineNo;
SalesL.Type:=SalesL.Type::"G/L Account";
SalesL."No.":=BillItems."GL Code";
SalesL.VALIDATE("No.");
SalesL.Description:=BillItems.Description;
SalesL."Unit of Measure Code":='FEE';
SalesL.Quantity:=1;
SalesL.VALIDATE(Quantity);
SalesL."Unit Price":=BillItems."Bill Item Amount";
SalesL.VALIDATE("Unit Price");
SalesL."Shortcut Dimension 1 Code":=BillItems."Activity Code";
SalesL.VALIDATE("Shortcut Dimension 1 Code");
SalesL."Shortcut Dimension 2 Code":=BillItems."Budget Line Code";
SalesL.VALIDATE("Shortcut Dimension 2 Code");
SalesH."Shortcut Dimension 1 Code":=BillItems."Activity Code";
SalesH.VALIDATE("Shortcut Dimension 1 Code");
SalesH."Shortcut Dimension 2 Code":=BillItems."Budget Line Code";
SalesH.VALIDATE("Shortcut Dimension 2 Code");
SalesL.INSERT;
UNTIL BillItems.NEXT=0;
rRec."Invoice No.":=DocumentNo;
rRec."Invoice Created?":=TRUE;
rRec.Select:=FALSE;
rRec.MODIFY;
//Update No. Series
NoSeries.SETRANGE("Series Code",'INVOICE');
IF NoSeries.FINDFIRST THEN
BEGIN
NoSeries."Last No. Used":=DocumentNo;
NoSeries.MODIFY;
END;
////
0 -
Hello Phogue,
I have attached the code in PDF since other formats are not supported and the code is too long.
Please do not hesitate to ask me any thing that be required to get me out of this hook.
Thanking you in advance,
Fredrick.0 -
If you run a debugger, when exactly (in the code) does the error appear?1
-
Your code should looks like:
rRec.RESET;
rRec.COPYFILTERS(Rec);
rRec.SETRANGE("Invoice Created?", FALSE);
rRec.SETRANGE("Receipt Created?", FALSE);
rRec.SETRANGE("Bill Status", '2');
rRec.SETFILTER(rRec."Zone Code", '<>%1', 0);
rRec.SETRANGE(Status, rRec.Status::Permanent);
IF rRec.FINDSET THEN
REPEAT
SalesRecSetup.GET;
SalesH.RESET;
SalesH.INIT;
SalesH."Document Type" := SalesH."Document Type"::Invoice;
SalesH."No. Series" := SalesRecSetup."Invoice Nos.";
SalesH.INSERT(TRUE);
SalesH."Control Number" := rRec."Bill Control Number";
SalesH.VALIDATE("Sell-to Customer No.", rRec."Customer No.");
SalesH.MODIFY(TRUE);
and then continue with lines
1 -
... and hint: Do not use characters with potentially special meaning (?) in column names.1
-
@Nagaboona - You need to debug it out and see where is the glitch , going through this lengthy code wont help.
May be some sequence would be wrongThanks
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/1 -
Hello Phogue,
I did run the debugger it stops at table 474 - Job queue log entry
Function - Get Error Message.0 -
Hello Lubost,
Thanks I tried to change change the code as of your suggestion but I keep getting the same error.0 -
Continued with lines:
LineNo := 10000;
BillItems.RESET;
BillItems.SETRANGE("Bill ID", rRec.Bill_ID);
IF BillItems.FINDSET THEN
REPEAT
SalesL.RESET;
SalesL.INIT;
SalesL."Document Type":=SalesH."Document Type";
SalesL."Document No.":=SalesH."No.";
SalesL."Line No.":=LineNo;
SalesL.Type:=SalesL.Type::"G/L Account";
SalesL.VALIDATE("No.", BillItems."GL Code");
SalesL.Description:=BillItems.Description;
SalesL."Unit of Measure Code":='FEE';
SalesL.VALIDATE(Quantity, 1);
SalesL.VALIDATE("Unit Price". BillItems."Bill Item Amount");
SalesL.VALIDATE("Shortcut Dimension 1 Code", BillItems."Activity Code");
SalesL.VALIDATE("Shortcut Dimension 2 Code", BillItems."Budget Line Code");
SalesH.VALIDATE("Shortcut Dimension 1 Code", BillItems."Activity Code");
SalesH.VALIDATE("Shortcut Dimension 2 Code", BillItems."Budget Line Code");
SalesH.VALIDATE("Shortcut Dimension 2 Code");
SalesL.INSERT;
UNTIL BillItems.NEXT=0;
SalesH.MODIFY;
rRec."Invoice No.":=SalesH."No.";
rRec."Invoice Created?":=TRUE;
rRec.Select:=FALSE;
rRec.MODIFY;
and without any touch to NoSeries table.
Modifying header dimensions again and again with each line has no effect, because:
- last value will be used
- validation trigger in header changes all lines values.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