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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Inserting data into LedjerJournalHeaderEntity and LedjerJournalLineEntity

(0) ShareShare
ReportReport
Posted on by

Hi Guys,

I am stuck with inserting records into mentioned entities in X++. Never used entities before so not sure how it should be working.

Currently I am trying to insert any test data but each time get errors.

For example, when trying to insert data into LedjerJournalHeaderEntity, an exeption "The value *** in field 'Name' is not found in the related table 'Name of journal' occurs.

Any code examples and suggestions where to look for related tables which are causing exeptions would be appreciated.

Thank you for help!

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Inserting data into LedjerJournalHeaderEntity and LedjerJournalLineEntity

    This error is not specific to entities, you would get the same error if you tried to insert a table buffer in x++.

    The error message says that you are trying to use such value in JournalName field which can't be found in Journal names table.

    If you look at LedgerJournalTable table, you see that there's a relation to LedgerJournalName table, using JournalName field. So, JournalName field only accepts values that exist in LedgerJournalName table.

    You can also try to create a journal in the user interface to get a different view to the data and the validations. Perhaps it helps you understand the validations better. And you can try to export the entity data (for example to Excel) to get nice examples of actual data.

  • Community Member Profile Picture
    on at
    RE: Inserting data into LedjerJournalHeaderEntity and LedjerJournalLineEntity

    Actually, I also thought like that and have already tried using values from JournalName field in LedgerJournalName table. But the error remained that's why I decided to ask here.

    Looks like I am doing something wrong.

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at
    RE: Inserting data into LedjerJournalHeaderEntity and LedjerJournalLineEntity

    Hi,

    Are you inserting into the correct Legal entity? How are you inserting data into the entity?

  • nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Inserting data into LedjerJournalHeaderEntity and LedjerJournalLineEntity

    Could be.

    If you need any comments or suggestions regarding your code, you can share it here.

    Also please check that you are running your code in the same company where the journal name is set up.

  • Community Member Profile Picture
    on at
    RE: Inserting data into LedjerJournalHeaderEntity and LedjerJournalLineEntity

    Changing company helped me!

    I used for 'Payroll' value as JournalName  but another error occured:

    'Journal name Payroll does not support journal type Daily.'

    Here is my test code:

               entity.IntegrationKey = "Report";

               entity.JournalName = "Payroll";

               entity.IsPosted = NoYes::No;

               entity.JournalTotalCredit = 100;

               entity.JournalTotalDebit = 200;

               entity.insert();

    As I understood Daily is a default value for JournalType. But as JournalType is not specified in entity fields then I need to add JournalType or there is another way?

  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Inserting data into LedjerJournalHeaderEntity and LedjerJournalLineEntity

    Try to insert data via UI, and check the result in table browser or entity export to see an example with good data that the system accepts.

    You can also debug the validations in validateWrite method of the table to understand them better. So far I don't see any x++ syntax issue, instead you must understand the data requirements better. 

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at
    RE: Inserting data into LedjerJournalHeaderEntity and LedjerJournalLineEntity

    You can't create Payroll journal using LedgerjournalheaderEntity. It is set to accept only Daily journals.

    pastedimage1599752120315v1.png

    You will need to create a new entity for this.

  • Suggested answer
    Sukrut Parab Profile Picture
    71,699 Moderator on at
    RE: Inserting data into LedjerJournalHeaderEntity and LedjerJournalLineEntity

    Along with entity option , you can also take reference of MCRLedgerJournl* classes to create journals using x++. Just do find references and you will find plenty of options how they are used in standard code.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 1,922

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 1,922

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 835 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans