Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Primary keyvalue(s) Journal_Batch_Name, Journal_Template_Name, Line_No are missing in insert command. Make sure that all primary keys on the page are backed by a control in order to be set

(0) ShareShare
ReportReport
Posted on by

I'm getting this error when trying to create a line in Gen_ Journal Line through a published oData web service for Id 39, called "DiarioGeral":

"Primary keyvalue(s) Journal_Batch_Name, Journal_Template_Name, Line_No are missing in insert command. Make sure that all primary keys on the page are backed by a control in order to be set"

My C# code is :

DiarioGeral dg = new DiarioGeral();
dg.Journal_Template_Name = "COBRANÇAS";
dg.Journal_Batch_Name = "82";
dg.Line_No = 50000;

nav.AddToDiarioGeral(dg);
nav.SaveChanges();

any ideas?

*This post is locked for comments

  • Community Member Profile Picture
    on at
    RE: Primary keyvalue(s) Journal_Batch_Name, Journal_Template_Name, Line_No are missing in insert command. Make sure that all primary keys on the page are backed by a control in order to be set

    Those fields are filled in my code.

    I'm printing those values before calling SaveChanges().

    Like I said, in my local NAV installation the code works.

    the same code in the NAV installed in the server , gives that error.

    Is it something that I have to do directly in NAV?

  • Suggested answer
    Suresh Kulla Profile Picture
    47,791 on at
    RE: Primary keyvalue(s) Journal_Batch_Name, Journal_Template_Name, Line_No are missing in insert command. Make sure that all primary keys on the page are backed by a control in order to be set

    Nelson,

    Add the primary Key fields that is Journal Batch Name, Journal Template Name and Line No. onto the page 39 and try again.

  • Community Member Profile Picture
    on at
    RE: Primary keyvalue(s) Journal_Batch_Name, Journal_Template_Name, Line_No are missing in insert command. Make sure that all primary keys on the page are backed by a control in order to be set

    More information.

    I've installed the same NAV version on my laptop and it work's just fine with the CRONUS demo database.

    Creates the lines with no problem.

    The thing I noted is that my local database is case-sensitive and the one that has the error is not. Don't know if this can cause problems.

  • Community Member Profile Picture
    on at
    RE: Primary keyvalue(s) Journal_Batch_Name, Journal_Template_Name, Line_No are missing in insert command. Make sure that all primary keys on the page are backed by a control in order to be set

    Please note that I'm able to create Customers, list customers, list General Ledger Entries, etc... via oData Web Service

  • Community Member Profile Picture
    on at
    RE: Primary keyvalue(s) Journal_Batch_Name, Journal_Template_Name, Line_No are missing in insert command. Make sure that all primary keys on the page are backed by a control in order to be set

    I'm just trying to create the line in the "Gen_ Jornal Line" table .

    The Post/Register will be done manually in the NAV's interface.

    What I get is :

    System.Data.Services.Client.DataServiceRequestException: An error occurred while processing this request. ---> System.Data.Services.Client.DataServiceClientException: <?xml version="1.0" encoding="utf-8"?><m:error xmlns:m="schemas.microsoft.com/.../metadata&quot;><m:code /><m:message xml:lang="en-US">Primary keyvalue(s) Journal_Batch_Name, Journal_Template_Name, Line_No are missing in insert command. Make sure that all primary keys on the page are backed by a control in order to be set.</m:message></m:error>

      --- End of inner exception stack trace ---

      at System.Data.Services.Client.SaveResult.HandleResponse()

      at System.Data.Services.Client.BaseSaveResult.EndRequest()

      at System.Data.Services.Client.DataServiceContext.SaveChanges(SaveChangesOptions options)

      at System.Data.Services.Client.DataServiceContext.SaveChanges()

      at NAVTest2.Form1.button1_Click(Object sender, EventArgs e) in c:\Users\nandre\Documents\Visual Studio 2013\Projects\NAVTest2\NAVTest2\Form1.cs:line 140

  • Community Member Profile Picture
    on at
    RE: Primary keyvalue(s) Journal_Batch_Name, Journal_Template_Name, Line_No are missing in insert command. Make sure that all primary keys on the page are backed by a control in order to be set

    Hi, yes I just published the page.

    Shouldn't this work?

    We did the same for customers and we are able to create customers from an external c# web page.

  • Suggested answer
    keoma Profile Picture
    32,727 on at
    RE: Primary keyvalue(s) Journal_Batch_Name, Journal_Template_Name, Line_No are missing in insert command. Make sure that all primary keys on the page are backed by a control in order to be set

    did you simply puplish the page ?

    better develop a new codeunit.

    check, if you get an inner exception for more details.

    also follow community.dynamics.com/.../125901

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

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
Community Member Profile Picture

Community Member 2

#2
EH-09052238-0 Profile Picture

EH-09052238-0 1

#2
Sohail Ahmed Profile Picture

Sohail Ahmed 1

Featured topics

Product updates

Dynamics 365 release plans