web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Multi selection in Grid Using ax 2009

(0) ShareShare
ReportReport
Posted on by 535

Hi Experts,

Automate Free Text Invoice In AR Module, While posting a invoice using Invoice staging form( Am selected 3 rows in grid to post at one time) after posting it posted only first row in grid. It posted first row three times . I used below syntax to get next record,

for(localCustInvoiceTarns = CustInvoiceTrans_DS.getFirst(true) ? CustInvoiceTrans_DS.getFirst(true) : CustInvoiceTrans_DS.cursor(); localCustInvoiceTarns; localCustInvoiceTarns = CustInvoiceTrans_DS.getNext())

I don't know what is the issue? Please help me to resolve.

Thanks in advance and Regards,

Vignesh

*This post is locked for comments

I have the same question (0)
  • Vignesh R Profile Picture
    535 on at

    Hi Crispin,

    I tried what way you suggested, still it posting First row as three times . Is there anyway to solve this issue?

    Thanks in advance and regards,

    Vignesh

  • Vignesh R Profile Picture
    535 on at

    Hi Crispin,

    Check it and Let me know. I wrote class to Insert record to target table and posting invoice.

    ---------------------------------------------------------------------------------------------------------------------------

    Post Button in form- Clicked Method()

    for(erb_InvoiceStagingDemoTable1 = ERB_InvoiceStagingDemoTable_ds.getFirst(1); erb_InvoiceStagingDemoTable1;erb_InvoiceStagingDemoTable1 = ERB_InvoiceStagingDemoTable_ds.getNext())

       {

           PostFreeTextInvoice::main();

       }

    ---------------------------------------------------------------------------------------------------------------------------

    This is the class to insert record to target table and posting invoice also.

    static void main()
    {
    CustInvoiceTable custInvoiceTable;
    CustInvoiceLine custInvoiceLine;
    CustPostInvoice custPostInvoice;
    ERB_InvoiceStagingDemoTable erb_InvoiceStagingDemoTable;
    LineNum lineNum;
    int i;
    ;
    select * from erb_InvoiceStagingDemoTable;
    {
    ttsbegin;
    custInvoiceTable.initValue();
    custInvoiceTable.OrderAccount = erb_InvoiceStagingDemoTable.Customer;
    custInvoiceTable.InvoiceAccount = erb_InvoiceStagingDemoTable.Customer;
    custInvoiceTable.numberSequenceGroup = erb_InvoiceStagingDemoTable.NumberSequenceGroup;
    custInvoiceTable.InvoiceDate = erb_InvoiceStagingDemoTable.InvoiceDate;
    custInvoiceTable.CurrencyCode = erb_InvoiceStagingDemoTable.Currency;
    // custInvoiceTable.WorkMonth = erb_InvoiceStagingDemoTable.WorkMonth;
    custInvoiceTable.InvoiceId = erb_InvoiceStagingDemoTable.InvoiceNo;
    custInvoiceTable.LanguageId = "EN-US";
    custInvoiceTable.insert();
    info("Header record inserted successfully");

    // if(custInvoiceLine)
    //{
    custInvoiceLine.initValue();
    custInvoiceLine.ParentRecId = custInvoiceTable.RecId;
    custInvoiceLine.LedgerAccount = "31110001";
    custInvoiceLine.TaxItemGroup = erb_InvoiceStagingDemoTable.ItemSalesTaxGroup;
    custInvoiceLine.AmountCur = erb_InvoiceStagingDemoTable.InvoiceAmount;
    custInvoiceLine.insert();
    info("Line record inserted successfully");
    // }
    }
    ttscommit;
    custPostInvoice = new CustPostInvoice(custInvoiceTable);
    custPostInvoice.run();


    }

  • Vignesh R Profile Picture
    535 on at

    Hi Crispin,

    It is always taking first record in grid. It is not taking selected records in grid. Suggest me solution for this issue.

    Thanks in advance and Regards,

    Vignesh

  • Vignesh R Profile Picture
    535 on at

    Hi

    InvoiceStagingDemoTable1 - it's buffer name in clicked method , In main method - InvoiceStagingDemoTable

  • Verified answer
    Anton Venter Profile Picture
    20,345 Super User 2025 Season 2 on at

    You should use the MultiSelectionHelper class when you want to get the selected records from a grid. Like already mentioned, you are not passing the selection to your class. You can use the MultiSelectionHelper class in the main method of your class for this purpose.

  • Vignesh R Profile Picture
    535 on at

    Hi Anton and Crispin,

    Check clicked method and let me know any wrong in this

    Void clicked()

    {

       MultiSelectionHelper          selectionHelper = MultiSelectionHelper::construct();

       Set                           selectedRecords = new Set(Types::Record);

       ERB_InvoiceStagingDemoTable   erb_InvoiceStagingDemoTable1;

       CustInvoiceTable              custInvTlb;

       ;

       super();

       selectionHelper.parmDataSource(ERB_InvoiceStagingDemoTable_DS);

       erb_InvoiceStagingDemoTable1  = selectionHelper.getFirst();

       if (erb_InvoiceStagingDemoTable1.RecId)

       {

           while (erb_InvoiceStagingDemoTable1)

           {

               selectedRecords.add(erb_InvoiceStagingDemoTable1);

                PostFreeTextInvoice::main();

               erb_InvoiceStagingDemoTable1 = selectionHelper.getNext();

           }

       }

       }

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Ali Zaidi Profile Picture

Ali Zaidi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans