web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Business Central forum

Error: Invoice ID is not specified; when posting sales order in test function

(0) ShareShare
ReportReport
Posted on by 35

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.   

Categories:
I have the same question (0)
  • Othman Abo Salah Profile Picture
    70 on at

    Can you please share with me how did you manage to solve that issue? 

  • Hannes Holst Profile Picture
    5,767 on at

    Hi,

    This error is raised in the following scenrario:

    SalesLine.Get(SalesLine."Document Type"::Order, '1001', 10000);

    SalesLine2.Get(SalesLine2."Document Type"::Order, '1001', 10000);
    SalesLine2.Quantity := 2; // could be a change to any field that raises the error
    SalesLine2.Modify();

    SalesLine."Unit Price" := 9.99;
    SalesLine.Modify(); // error happens here because the rceord is not the latest version anymore

    The example is a common problem in code. Unfortunately, Microsoft did change the content of the error message so that it appears to be a new problem. But, actually it isn't.
    I don't remember the error message from the older versions (pr-AL)

    Hannes

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans