Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Data is not fetching from table to form

Posted on by Microsoft Employee

Hi Experts,

 i have created the payment journal, its storing in table but its not fetching into form, header level its fetching the data from table to form but  line level only im facing issue to fetch the data from table to form please tell me some solution to solve this issue.

Thanks & Regards,

Ashwini

*This post is locked for comments

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Data is not fetching from table to form

    Try to create one LedgerJournalTrans line for this journal in the user interface. Then compare it in the table browser to the one that you created in x++. Most likely you see that some info is missing from the one that you created with x++. Then fix your code to produce similar lines than the one that was created in UI.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Data is not fetching from table to form

    Hi

    i have removed the code which your mentioned above now also i m facing same  issue i did debug and checked the line values are getting and store in  table also but not showing in for, please see the below code which i changed now,

    static void CustPaymJournalCreate(Args _args)

    {

       CustTable                           custTable;

       BankAccountTable                    bankAccountTable;

       Ledgerjournalname                   ledgerjournalname;

       LedgerjournalTable                  ledgerjournalTable;

       LedgerjournalTrans                  ledgerjournalTrans;

       LedgerjournalCheckPost              ledgerjournalCheckPost;

       DimensionAttributeValueCombination  dimensionAttribute;

       NumberSeq                           numberSeq;

       CompanyBankAccountId                bankAccountId;

       DimensionDisplayValue               ledgerDimension;

       AccountNum                          custAccountNum;

       LedgerJournalACTypeAll              ledgerJournalACTypeAll;

       LedgerTransType                     ledgerTransType;

       LedgerJournalACType                 ledgerJournalACType;

       bankAccountId   = "CITI-CHN";

       custAccountNum  = "CA005";

       //select firstOnly ledgerjournalname;

       //select firstOnly custTable

           //where custTable.AccountNum like 'CA006';

       //select firstOnly custTableBank

           //where custTable.AccountNum like 'Yes-INR';

       // create journal

       select ledgerjournalname

           where ledgerjournalname.JournalName == "CRJ";

       ledgerjournalTable.JournalName = ledgerjournalname.JournalName;

       ledgerjournalTable.initFromLedgerJournalName();

       ledgerjournalTable.JournalNum  = JournalTableData::newTable(ledgerjournalTable).nextJournalId();

       ledgerjournalTable.insert();

       LEDGERJOURNALTRANS.JOURNALNUM               = LEDGERJOURNALTABLE.JOURNALNUM;

       NUMBERSEQ                                   = NUMBERSEQ::NEWGETVOUCHERFROMID((LEDGERJOURNALNAME.NUMBERSEQUENCETABLE));

       LEDGERJOURNALTRANS.VOUCHER                  = NUMBERSEQ.VOUCHER();

       ledgerjournalTrans.CurrencyCode             = "INR";

       ledgerjournalTrans.ExchRate                 = Currency::exchRate(ledgerjournalTrans.CurrencyCode);

       ledgerjournalTrans.AccountType              = LedgerJournalACType::Cust;

       if(LedgerJournalACType::Cust == ledgerJournalTrans.AccountType)

       {

           select RecId from dimensionAttribute

               where dimensionAttribute.DisplayValue       ==  custAccountNum

               && dimensionAttribute.LedgerDimensionType   ==  LedgerDimensionType::Account;

           if(dimensionAttribute.RecId != 0)

           {

               ledgerjournalTrans.LedgerDimension  = dimensionAttribute.RecId;

           }

           else

           {

               throw Error("Not available");

           }

       }

       ledgerjournalTrans.Txt                      = 'Customer payment journal demo';

       ledgerjournalTrans.AmountCurCredit          = 2000;

       ledgerjournalTrans.TransDate                = systemDateGet();

       ledgerjournalTrans.MarkedInvoice            = 'IND-DN-16-17-10026';

       ledgerjournalTrans.OffsetAccountType        = LedgerJournalACType::Bank;

       if(LedgerJournalACType::Bank == ledgerjournalTrans.OffsetAccountType)

       {

           select RecId from dimensionAttribute

               where dimensionAttribute.DisplayValue       ==  bankAccountId

               && dimensionAttribute.LedgerDimensionType   ==  LedgerDimensionType::Account;

           if(dimensionAttribute.RecId)

           {

               ledgerjournalTrans.OffsetLedgerDimension    =   dimensionAttribute.RecId;

           }

            else

           {

               throw Error("Not available");

           }

       }

       ledgerjournalTrans.insert();

    }

    please the below screen shots

    line table withe data for HTL - 000361

    8468.222.png

    form 

    8468.222.png

    Please give any solutions .

    Thank you

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Data is not fetching from table to form

    In your code, you are trying to select all LedgerJournalTrans records that are related to the LedgerJournalTable that you just created. But there are no such records at that point. So your code execution never goes to the place where you are creating the line = inside the while statement. If you debug your code (highly recommended when you want to troubleshoot issues), you will notice that yourself.

    Just remove this code and you'll be fine:

    While select * from ledgerjournalTable
    join ledgerjournalTrans
    where ledgerjournalTrans.JournalNum == ledgerjournalTable.JournalNum
    


    Also, you don't have to use a transaction (ttsbegin/ttscommi) for insert operations. It's required only for update and delete operations.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Data is not fetching from table to form

    Hi Nikolaos,

    thank you for your reply,  i have creted the cust payment journal header is showing in form but form not showing i have checked the table realetions also in table level everything is ok  eventhough not showing in line level.

    please see the screen shots,

    Account Receivables-> payment journal

    8688.ax6.png

    payment journal header

    2ax.png

    payment journal line

    3157.ax3.png

    static void CustPaymJournalCreate(Args _args)
    {
    CustTable custTable;
    BankAccountTable bankAccountTable;
    Ledgerjournalname ledgerjournalname;
    LedgerjournalTable ledgerjournalTable;
    LedgerjournalTrans ledgerjournalTrans;
    LedgerjournalCheckPost ledgerjournalCheckPost;
    DimensionAttributeValueCombination dimensionAttribute;
    NumberSeq numberSeq;
    CompanyBankAccountId bankAccountId;
    DimensionDisplayValue ledgerDimension;
    AccountNum custAccountNum;
    LedgerJournalACTypeAll ledgerJournalACTypeAll;
    LedgerTransType ledgerTransType;
    LedgerJournalACType ledgerJournalACType;
    bankAccountId = "CITI-CHN";
    custAccountNum = "CA005";

    // create journal
    select ledgerjournalname
    where ledgerjournalname.JournalName == "CRJ";

    ttsBegin;
    ledgerjournalTable.JournalName = ledgerjournalname.JournalName;
    ledgerjournalTable.initFromLedgerJournalName();
    ledgerjournalTable.JournalNum = JournalTableData::newTable(ledgerjournalTable).nextJournalId();
    ledgerjournalTable.insert();
    ttsCommit;


    While select * from ledgerjournalTable
    join ledgerjournalTrans
    where ledgerjournalTrans.JournalNum == ledgerjournalTable.JournalNum
    // create journal Lines

    ledgerjournalTrans.initValue();
    ledgerjournalTrans.JournalNum = ledgerjournalTable.JournalNum;
    ledgerjournalTrans.initFromLedgerJournalTable_LT(ledgerjournalTable);

    ttsBegin;
    ledgerjournalTrans.JournalNum = ledgerjournalTable.JournalNum;
    numberSeq = NumberSeq::newGetVoucherFromId((ledgerjournalname.NumberSequenceTable));
    ledgerjournalTrans.Voucher = numberSeq.voucher();
    ledgerjournalTrans.CurrencyCode = "INR";
    ledgerjournalTrans.ExchRate = Currency::exchRate(ledgerjournalTrans.CurrencyCode);
    ledgerjournalTrans.AccountType = LedgerJournalACType::Cust;

    if(LedgerJournalACType::Cust == ledgerJournalTrans.AccountType)
    {
    select RecId from dimensionAttribute
    where dimensionAttribute.DisplayValue == custAccountNum
    && dimensionAttribute.LedgerDimensionType == LedgerDimensionType::Account;

    if(dimensionAttribute.RecId != 0)
    {
    ledgerjournalTrans.LedgerDimension = dimensionAttribute.RecId;
    }
    else
    {
    throw Error("Not available");
    }
    }
    ledgerjournalTrans.Txt = 'Customer payment journal demo';
    ledgerjournalTrans.AmountCurCredit = 2000;
    ledgerjournalTrans.TransDate = systemDateGet();
    ledgerjournalTrans.MarkedInvoice = 'IND-DN-16-17-10026';
    ledgerjournalTrans.OffsetAccountType = LedgerJournalACType::Bank;
    if(LedgerJournalACType::Bank == ledgerjournalTrans.OffsetAccountType)
    {
    select RecId from dimensionAttribute
    where dimensionAttribute.DisplayValue == bankAccountId
    && dimensionAttribute.LedgerDimensionType == LedgerDimensionType::Account;

    if(dimensionAttribute.RecId)
    {
    ledgerjournalTrans.OffsetLedgerDimension = dimensionAttribute.RecId;
    }
    else
    {
    throw Error("Not available");
    }
    }


    ledgerjournalTrans.insert();
    ttsCommit;

    }

    above code only im using  and i have checked the table releations between header and line table please see the below screen shots,

    8688.ax6.png

    please give any solution to get the data line as well .

    Thanks & Regards

    Ashwini.E

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Data is not fetching from table to form

    What is the default form that you are using? Could you share a screenshot to better illustrate what is the problem that you are facing? And also describe what is the actual vs expected outcome.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Data is not fetching from table to form

    Hi Ievgen,

    Thank you for reply, we are using this two table  Ledger Journal Trans and Ledger journal Table both tables are default table and default form im using , i didt use any customisation in this form eventhough its  not showing in line level. please give some idea to solve this issue.

    Thanks & Regards,

    Ashwini.E

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Data is not fetching from table to form

    Hi Ashwini.123,

    You should create a relation on the table level between header table and lines table. Then add 2 data sources to a form and join them. AX will use relation defined to build a link and show only lines related to selected header.

    If you have issue with it you need to provide additional information, like relations that you have on the header and lines, data sources of the form etc.

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,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans