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 :
Microsoft Dynamics AX (Archived)

when i import ledgerjournal transaction from Excel to Ax through X++ code i am getting this error Function DimensionHierarchy::getHierarchyIdByHierarchyType has been incorrectly called

(0) ShareShare
ReportReport
Posted on by

 int     dynamicCol;
    str     tranDate;
    SLSalesPurchLedgerJourLinesImport       sLSalesPurchLedgerJourLinesImport;
    this.initilizeExcel(_filePath);


    do
    {
        row++;
        journalTrans.ledgerJournalTrans().clear();
        tranDate = cells.item(row, 1).value().bStr();
        journalTrans.parmTransDate(str2Date(tranDate,123));
        journalTrans.parmJournalNum(cells.item(row,2).value().bStr());
        journalTrans.parmVoucher(cells.item(row, 4).value().bStr());
        custAccount = cells.item(row, 5).value().bStr();
        if(custAccount == "")
           custAccount = int2str(cells.item(row, 5).value().int());
        journalTrans.parmTxt(cells.item(row,6).value().bStr());
        journalTrans.parmAmountCurDebit(cells.item(row, 7).value().double());
        journalTrans.parmAmountCurCredit(cells.item(row,8).value().double());
        journalTrans.parmCurrencyCode(cells.item(row, 9).value().bStr());
        journalTrans.parmExchRate(cells.item(row,10).value().double());

        journalTrans.parmAccountType(LedgerJournalACType::Ledger);
        journalTrans.parmLedgerDimension(DimensionStorage::getDynamicAccount(custAccount, LedgerJournalACType::Ledger));
        journalTrans.parmOffsetAccountType(LedgerJournalACType:: Ledger );
        journalTrans.parmOffsetLedgerDimension(CustLedgerAccounts::SummaryLedgerDimension(custAccount, ""));


        journalTrans.save();
        ledgerJournalTrans = journalTrans.ledgerJournalTrans();

        if (ledgerJournalTrans &&!ledgerJournalTrans.OffsetLedgerDimension)
        {
        ledgerJournalTrans.selectForUpdate(true);
        ledgerJournalTrans.OffsetLedgerDimension = LedgerJournalTrans.getLedgerDimensionForLedgerType(DimensionStorage::getLedgerDefaultAccountFromLedgerDim(CustLedgerAccounts::SummaryLedgerDimension("1652-000010", "")), LedgerJournalTrans.Company);
        ledgerJournalTrans.Voucher =  journalTrans.parmVoucher(cells.item(row, 4).value().bStr());
        ledgerJournalTrans.update();
        }


        type = cells.item(row+1, 1).value().variantType();
    }

     while (type != COMVariantType::VT_EMPTY);
        application.quit();





    info(strFmt("Journal No. %1.", journalTable.ledgerJournalTable().JournalNum));
}

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Zain Bokhari Profile Picture
    3,208 Moderator on at
    RE: when i import ledgerjournal transaction from Excel to Ax through X++ code i am getting this error Function DimensionHierarchy::getHierarchyIdByHierarchyType has been incorrectly called

    Hi,

    Please refer to the link below:

    https://dynamicsuser.net/ax/f/developers/50288/post-voucher-using-x-code/336436#pi2486filter=answers&pi2486scroll=true

  • Zain Bokhari Profile Picture
    3,208 Moderator on at
    RE: when i import ledgerjournal transaction from Excel to Ax through X++ code i am getting this error Function DimensionHierarchy::getHierarchyIdByHierarchyType has been incorrectly called

    [duplicated]

  • Zain Bokhari Profile Picture
    3,208 Moderator on at
    RE: when i import ledgerjournal transaction from Excel to Ax through X++ code i am getting this error Function DimensionHierarchy::getHierarchyIdByHierarchyType has been incorrectly called

    [Deleted]

  • Community Member Profile Picture
    on at
    RE: when i import ledgerjournal transaction from Excel to Ax through X++ code i am getting this error Function DimensionHierarchy::getHierarchyIdByHierarchyType has been incorrectly called

    HI that link refer only table data when i post ledgerdimension how to validate the data.

  • Community Member Profile Picture
    on at
    RE: when i import ledgerjournal transaction from Excel to Ax through X++ code i am getting this error Function DimensionHierarchy::getHierarchyIdByHierarchyType has been incorrectly called

    HI zain Thanks for your suggest i need to import  data from excel  not created journals through code.

    can you please help me how to import  ledgerjournal trans data from ecxcel to ax through x++ code.

  • Suggested answer
    Zain Bokhari Profile Picture
    3,208 Moderator on at
    RE: when i import ledgerjournal transaction from Excel to Ax through X++ code i am getting this error Function DimensionHierarchy::getHierarchyIdByHierarchyType has been incorrectly called

    Just search for it on google, you will find plenty of jobs written by developers to import GL transactions from excel. For instance:

    one

    two

    three

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: when i import ledgerjournal transaction from Excel to Ax through X++ code i am getting this error Function DimensionHierarchy::getHierarchyIdByHierarchyType has been incorrectly called

    hi zain,

    str        transdate;

    transdate = cells.item(row,1).value().bstr();

    ledgerjournal.transdate = str2date(transdate,123);

    but i got  excel value to variable of transdate

    but when i assign the variable to ledgerjournal.transdate its not getting value why. can you please help me

  • Suggested answer
    Zain Bokhari Profile Picture
    3,208 Moderator on at
    RE: when i import ledgerjournal transaction from Excel to Ax through X++ code i am getting this error Function DimensionHierarchy::getHierarchyIdByHierarchyType has been incorrectly called

    That is probably because it is stored as a date value and you are trying to read it as a string?

    Try this cells.item(row,2).value().date();

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

#2
NNaumenko Profile Picture

NNaumenko 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans