Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

X++ code to create General Journal (The main account 0 does not exist.) , Error found when validating record.

Posted on by 570

Hello..

I used these article to create general transaction (Header and lines)

https://community.dynamics.com/ax/b/axrajdipdas/archive/2013/04/16/dynamics-ax-2012-x-code-to-create-amp-post-general-Journal

https://community.dynamics.com/365/financeandoperations/b/axsupport/archive/2011/12/21/creating-general-journals-in-ax-2012-in-x

my code

static void Job12(Args _args)
{
    AxLedgerJournalTable header = new AxLedgerJournalTable();

    AxLedgerJournalTrans trans = new AxLedgerJournalTrans();

    container  ledgerDimensions, offsetDimensions;

   
    header.parmJournalName("CSH-001");   
    header.save();  

   
    trans.parmAccountType(LedgerJournalACType::Ledger);   
    trans.parmJournalNum(header.ledgerJournalTable().JournalNum);   
    ledgerDimensions = ["1101010000"];   
    trans.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(ledgerDimensions));   
    trans.parmAmountCurDebit(230);   
    offsetDimensions = ["9999999999"];   
    trans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId(offsetDimensions));   
    trans.save();


}


when run the job I got next error 

0882.main.png

Any help ..

Thank you in advance.

*This post is locked for comments

  • Ismail Mohamed Profile Picture
    Ismail Mohamed 570 on at
    RE: X++ code to create General Journal (The main account 0 does not exist.) , Error found when validating record.

    I tried as u said but also gave me error (The main account 1204010101 does not exist.)

    this photo of manual  insert in ax form

    led2.png

    when i tried to insert  by x++ by the next code 

        journalTrans.parmAccountType(LedgerJournalACType::Ledger);
        acctPattern = ["2107032000","2107032000",0];
        journalTrans.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(acctPattern));
    
        journalTrans.parmOffsetAccountType(LedgerJournalACType::Bank );
        offSetAcctPattern = ["1204010101","1204010101",0];
        journalTrans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId( offSetAcctPattern));

    Error is (The main account 1204010101 does not exist.)

    1204010101 is wrote right as first photo 
    also please tell me why you repeated the number  "1101010000" in this container in your replay 

    ["1101010000", "1101010000", 0]

    thank you sir

  • Suggested answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: X++ code to create General Journal (The main account 0 does not exist.) , Error found when validating record.

    It should be

    ledgerDimensions = ["1101010000", "1101010000", 0]

    0 means that you don't have any financial dimensions, try it and same way for offset account

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans