Invoice ID is not specified.
I am writing a test scenario for custom Business Central app. I have a simple case where I want to post a Sales Order. When I perform the posting step I get this error in BC:
The changes to the Sales Header record cannot be saved because some information on the page is not up-to-date. Close the page, reopen it and try again.
Code breaks in codeunit 80 (Sales-Post) inline 1317, on action DELETE, where Sales Header should be deleted. This kind of behavior is super strange. In case if I prepare Sales Order manually trough Web client and I try to post also manually, everything works as expected.
If I prepare Sales Order manually trough Web client and I do NOT perform any Post action and if I use this Sales Order in my test scenario only to execute Posting, everything works well also. What is super strange. So if I prepare Sales Order trough my code I get problems with posting, otherwise no.
Sales Order is prepared using functions in codeunit 130509 (Library - Sales), CreateSalesHeader and CreateSalesLine.
I was also comparing Sales Header record right before posting for both cases I mentioned above and honestly there is no difference except few DateTime fields.
In Event Viewer is also something. There is an error saying Invoice ID is not specified. Hm, what is that? Does anyone have any idea about that?
ERROR:
Server instance: BC140
Category: Sales Invoice Aggregator
ClientSessionId: ***************************
ClientActivityId: ***************************
ServerSessionUniqueId: ***************************
ServerActivityId ***************************
EventTime: 07/23/2019 06:52:20
Message Invoice ID is not specified.
ProcessId: 19512
Tag: 00006TK
ThreadId: 154
WARNING:
EventTime: 07/23/2019 06:52:21
Message (NavCSideException): RootException: NavCSideException
The changes to the Sales Header record cannot be saved because some information on the page is not up-to-date. Close the page, reopen it, and try again.
Identification fields and values:
Document Type='Order',No.='SO19-00832'
AppObjectType: CodeUnit
AppObjectId: 80
AL CallStack: "Sales-Post"(CodeUnit 80).DeleteAfterPosting line 8
"Sales-Post"(CodeUnit 80).FinalizePosting line 55
"Sales-Post"(CodeUnit 80).OnRun(Trigger) line 92
"Library - Sales"(CodeUnit 130509).DoPostSalesDocument line 44
"Library - Sales"(CodeUnit 130509).PostSalesDocument line 1
Steps To Reproduce
1.) Install TestToolKit
2.) Create Sales Header using function CreateSalesHeader in codeunit 130509 (Library - Sales).
3.) Create two Sales Lines using function CreateSalesLine in codeunit 130509 (Library - Sales).
4.) Perform post-action using function PostSalesDocument in codeunit 130509 (Library - Sales).
Here is my code where I prepare Sales Order:
// Prepare Sales Header
lcLib.CreateSalesHeader(lrSalesHdr, lrSalesHdr."Document Type"::Order, lrIcPartner."Customer No.");
lrSalesHdr.Validate("Location Code", 'ABOVE');
lrSalesHdr.Modify(true);
// Prepare Sales Line
lcLib.CreateSalesLine(lrSalesLine, lrSalesHdr, lrSalesLine.Type::Item, '20001', 2);
lrSalesLine.Validate("Location Code", 'ABOVE');
lrSalesLine.Modify(true);
// Post Sales Order
lcIvnNo := lrLib.PostSalesDocument(lrSalesHeader, true, true);
Versions:
- AL Language: 3.0.106655
- Business Central: W1 14.0 14.0.29530.0
UPDATE:
After a while, I realized that this problem persists only for Sales Orders created for any IC Partner as a customer. If I choose any other non-IC customer posting works well.
Why does this happen only when I post for IC?
I really don't understand what the error The changes to the Sales Header r... mean and how to fix it. I don't see why this is happening.