Skip to main content

Notifications

Announcements

No record found.

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
  • BarbarO Profile Picture
    BarbarO 8 on at
    Insertion issues in table ItemJournalLines
    Double post
  • BarbarO Profile Picture
    BarbarO 8 on at
    Insertion issues in table ItemJournalLines
    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.
     
     
  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 993 Super User 2024 Season 1 on at
    Insertion issues in table ItemJournalLines
    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
    BarbarO 8 on at
    Insertion issues in table ItemJournalLines
    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
    Mohana Yadav Profile Picture
    Mohana Yadav 60,062 Super User 2024 Season 2 on at
    Insertion issues in table ItemJournalLines
    Looks like L is missing in DEFAUT
  • BarbarO Profile Picture
    BarbarO 8 on at
    Insertion issues in table ItemJournalLines
    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;
                    }

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,904 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,605 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans