web
You’re offline. This is a read only version of the page.
close
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

I have the same question (0)
  • Suggested answer
    keoma Profile Picture
    32,729 on at

    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

  • Community Member Profile Picture
    on at

    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.

  • Community Member Profile Picture
    on at

    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

    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

    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.

  • Suggested answer
    Suresh Kulla Profile Picture
    50,247 Super User 2025 Season 2 on at

    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

    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?

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans