Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

multiple records select in grid (not manual) through code in AX 2009

Posted on by 5,901

hi All,

AX 2009

In ledger settlement form, when user select multiple records MANUALLY and clicked on Include button then as per standard functionality those line appeared in BELOW GRID as below

5126.a1.jpg

But user wants this process to AUTOMATE. So, i have added MARK check box in Ledger Trans table and marked the voucher based on excel template. That i have done through Import  voucher button clicked. Which voucher is matched with excel that voucher get mark = YES. It's working fine.

But when i clicked on INCLUDE button it's only insert SINGLE VOUCHER (FAQ-007702) in BELOW GRID as below. I expect to get voucher FAQ-007702, FAQ-007706, FAQ-007709

8551.a3.jpg

CODE : Include button > Clicked method >

void clicked()
{
    LedgerTrans ledgerTransLocal;
    ;
    
    ttsbegin;
    ledgerTransLocal.recordLevelSecurity(true);
    for (ledgerTransLocal = ledgerTrans_ds.getFirst(true) ? ledgerTrans_ds.getFirst(true) : ledgerTrans;
         ledgerTransLocal;
         ledgerTransLocal = ledgerTrans_ds.getNext())
    {
        element.includeTrans(ledgerTransLocal);
    }
    ttscommit;

    tmpLedgerTrans_ds.research();
    ledgerTrans_ds.next();
}


IncludeTrans() --

void includeTrans(LedgerTrans   _ledgerTrans)
{
    ;
    if (!mapTrans2TmpTrans.exists(_ledgerTrans.RecId))
    {
        tmpLedgerTrans.data(_ledgerTrans);
        tmpLedgerTrans.doInsert();

        mapTrans2TmpTrans.insert(_ledgerTrans.RecId,    tmpLedgerTrans.RecId);
        mapTmpTrans2Trans.insert(tmpLedgerTrans.RecId,  _ledgerTrans.RecId);

        balanceAmountMST  = _ledgerTrans.AmountMST;
    }
}

Kindly let me know how will achieve this ?

Please give me more shed on this.

  • @rp@n Profile Picture
    @rp@n 5,901 on at
    RE: multiple records select in grid (not manual) through code in AX 2009

    Yes bro,

    Actually I am only  worried about the bulk marked records. If it's like 150-200 then I am thinking how much it will take ?

    Because its looping entire ledger trans table and searching for the marked records one by one.

    As per the standard code , I dont think, insert_recordset will work.

    Can you please check finally, can I use insert_recordset?

    Please give me more shed on this

  • Gunjan Bhattachayya Profile Picture
    Gunjan Bhattachayya 35,421 on at
    RE: multiple records select in grid (not manual) through code in AX 2009

    Arpan, this class will work in the same way as the standard code was working. It will only consider the records selected by the user. This post might help you in understanding how this works.

    However, I believe that is not your requirement. You need to allow the user to mark the records and then include them as they click on the include button.

  • @rp@n Profile Picture
    @rp@n 5,901 on at
    RE: multiple records select in grid (not manual) through code in AX 2009

    Gunjan,

    I have checked multiselection helper class is there in AX 2009.

    If i use this class instead of mark yes.

    I mean now I have marked yes those vouchers which is matched with excel.

    Shall I do the same things with multiselection helper class without mark yes ?

    Please give me more shed on this

  • Gunjan Bhattachayya Profile Picture
    Gunjan Bhattachayya 35,421 on at
    RE: multiple records select in grid (not manual) through code in AX 2009

    Hi Arpan,

    I don't see a way to make it faster. You can try and check if you use insert_recordset, which should improve the performance.

  • @rp@n Profile Picture
    @rp@n 5,901 on at
    RE: multiple records select in grid (not manual) through code in AX 2009

    Gunjan,

    Point no 2 , is there any other way to make it fast??

  • Gunjan Bhattachayya Profile Picture
    Gunjan Bhattachayya 35,421 on at
    RE: multiple records select in grid (not manual) through code in AX 2009

    For #1, I you can add a clause to order by Voucher field and insert records.

    For #2, I am not sure how you can make it faster using this process.

  • @rp@n Profile Picture
    @rp@n 5,901 on at
    RE: multiple records select in grid (not manual) through code in AX 2009

    Gunjan,

    1. Proper order means in proper sequence like for example

    PV001

    PV001

    PV005

    PV005 

    2. I guess, previously it was fast inserting data in BOTTOM grid  because of the code like  table_ds.getfirst(), table _ds.getnext()

    Please give me more shed on this 

  • Gunjan Bhattachayya Profile Picture
    Gunjan Bhattachayya 35,421 on at
    RE: multiple records select in grid (not manual) through code in AX 2009

    Hi Arpan,

    1. What do you mean by proper order?

    2. I don't know how we can make it faster. How is the performance compared to the standard process?

  • @rp@n Profile Picture
    @rp@n 5,901 on at
    RE: multiple records select in grid (not manual) through code in AX 2009

    Gunjan,

    Thanks for your support...

    I have tried the above code and as expected , when i clicked on INCLUDE BUTTON, it's display Marked records from UPPER GRID to  BOTTOM GRID . 

    But two things as of now i have noticed.

    1. In BOTTOM GRID, records are not inserted in proper order.

    2. In BOTTOM GRID , it will take little bit time to get insert after clicked on Include button.

    For testing i have tested with only 5 vouchers. In real scenario, they might be import 200-300 vouchers at a time. 

    Note - Earlier it was happend very fast before my customization in Include button. 

    Include button code

    void clicked()
    {
        LedgerTrans ledgerTransLocal;
        ;
    
        /*ttsbegin;
        ledgerTransLocal.recordLevelSecurity(true);
        for (ledgerTransLocal = ledgerTrans_ds.getFirst(true) ? ledgerTrans_ds.getFirst(true) : ledgerTrans;
             ledgerTransLocal;
             ledgerTransLocal = ledgerTrans_ds.getNext())
        {
            element.includeTrans(ledgerTransLocal);
        }
        ttscommit;
    
        tmpLedgerTrans_ds.research();
        ledgerTrans_ds.next();*/
    
        ttsbegin;
        ledgerTransLocal.recordLevelSecurity(true);
    
        while select ledgerTransLocal
        where ledgerTransLocal.HCL_Mark == noyes::Yes
        {
            element.includeTrans(ledgerTransLocal);
        }
        ttscommit;
        tmpLedgerTrans_ds.research();
    }

    8168.a5.jpg

    Kindly let me know how will do record quick inserting in BOTTOM GRID?

    Please give me more shed on this

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    Gunjan Bhattachayya 35,421 on at
    RE: multiple records select in grid (not manual) through code in AX 2009

    Hi Arpan,

    You can try this code -

    void clicked()
    {
        LedgerTrans ledgerTransLocal;
        ;
        
        ttsbegin;
        ledgerTransLocal.recordLevelSecurity(true);
        while select ledgerJournalTransLocal
            where ledgerJournalTransLocal.Marked == NoYes::Yes
        {
            element.includeTrans(ledgerTransLocal);
        }
        ttscommit;
    
        tmpLedgerTrans_ds.research();
    }

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

Product updates

Dynamics 365 release plans