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 :
Small and medium business | Business Central, N...
Suggested Answer

Insertion issues in table ItemJournalLines

(0) ShareShare
ReportReport
Posted on by 8
Hello,
 
I have created a custom API page for the ItemJournalLines table/page and I'm trying to insert a record/line in the table using Postman. Everything is fine except for the journalBatchName, which is not the one I'm sending.
I've débugged my extension several times and figured out that the value of journalBatchName is taken into account but is then replaced at some point by another one (most likely the first record in the journalBatchName table).
I've also tried to debug the base app but the part where the value is changed doesn't seem to be debuggable, so I'm still in the dark and can't figure out how to solve this issue.
The action seems to happen on a OnModify trigger, which is even more weird to me, since I'm only inserting the line. If anyone has any idea how to solve this, it would be a great help.
 
(I'm working on the Cronus example database on Docker container)
 
 
Thanks in advance for any advice you can give
I have the same question (0)
  • BarbarO Profile Picture
    8 on at
    What I'm sending
    {
        "journalTemplateName": "ARTICLE",
        "journalBatchName": "DEFAUT",
        "documentNo":"Test",
        "quantity": 500,
        "description": "Test",
        "entryType": "Purchase",
        "unitofMeasureCode": "PCS",
        "genProdPostingGroup": "",
        "itemNo": "1896-S",
        "locationCode": "BLEU",
        "ShortcutDimCode1": "VENTES",
        "ShortcutDimCode2": "PEUGEOT"
    }

    What I'm getting : the journalBatchName is incorrect.
    {
        "amount": 391133.5,
        "appliesfromEntry": 0,
        "appliestoEntry": 0,
        "binCode": "",
        "countryRegionCode": "",
        "customField1": "",
        "customField2": "",
        "customField3": "",
        "customField4": "",
        "customField5": "",
        "customField6": "",
        "customField7": "",
        "customField8": "",
        "description": "Test",
        "discountAmount": 0,
        "documentDate": "0001-01-01",
        "documentNo": "TEST",
        "entryType": "Purchase",
        "externalDocumentNo": "",
        "genBusPostingGroup": "",
        "genProdPostingGroup": "",
        "id": "id",
        "indirectCost": 0,
        "ItemDescription": "",
        "itemNo": "1896-S",
        "journalBatchName": "TEST",
        "journalTemplateName": "ARTICLE",
        "lastModifiedDateTime": "2023-11-02T14:00:08.65Z",
        "lineNo": 30000,
        "locationCode": "BLEU",
        "postingDate": "0001-01-01",
        "quantity": 500,
        "reasonCode": "",
        "salespersPurchCode": "",
        "ShortcutDimCode1": "VENTES",
        "ShortcutDimCode2": "PEUGEOT",
        "ShortcutDimCode3": "",
        "ShortcutDimCode4": "",
        "ShortcutDimCode5": "",
        "ShortcutDimCode6": "",
        "ShortcutDimCode7": "",
        "ShortcutDimCode8": "",
        "transactionType": "",
        "transportMethod": "",
        "unitAmount": 782.267,
        "unitCost": 782.267,
        "unitofMeasureCode": "PCS"
    }
    What my API page looks like : Basically I have the API page settings and just the fields mapping. I have added custom fields, as you can see in the JSON body I'm receiving
                    field(journalBatchName; Rec."Journal Batch Name")
                    {
                        ApplicationArea = All;
                    }
  • Suggested answer
    Mohana Yadav Profile Picture
    61,005 Super User 2025 Season 2 on at
    Looks like L is missing in DEFAUT
  • BarbarO Profile Picture
    8 on at
    Hello, DEFAUT is the name of the journalBatch. The L is not missing. This is actually the French term for "default".
     
    If the journalBatchName I passed was incorrect I would get 
     
        "error": {
            "code": "Internal_InvalidTableRelation",
            "message": "The field Journal Batch Name of table Item Journal Line contains a value (DEFAUT) that cannot be found in the related table (Item Journal Batch).
    }
     
    Which is not the case.
     
    Thank you for your suggestion
     
     
  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,111 Moderator on at
    How do you handle the linenumbers?
    I do not see that you provide them to the API?
    Can that be the issue here?
  • BarbarO Profile Picture
    8 on at
    Hello,
     
    Thank you for your reply. The LineNo is handled by the autosplitkey parameter (https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/properties/devenv-autosplitkey-property) of the API page. It generates the LineNo automatically. I've tried disabling it but it ended up causing other problems.
     
    I suspected that it might have an impact on Journal Batch Name since it's also a PK (along with LineNo and JournalTemplateName) but I have another API page with the same parameter and similar PKs but it's working perfectly.
     
     
  • BarbarO Profile Picture
    8 on at
    Double post

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,135

#2
YUN ZHU Profile Picture

YUN ZHU 733 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 612

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans