Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

Loop form datasource

Posted on by 2,420

Good morning ,

As i have a requirement when i open a form and click at any point i mean any record

and i will click one button then there is one customized field on form which should generate number based on input given at the time of clicking that button.

Ex - i opened form

i selected 5 th record and i clicked button then dialog opens which ask me start from i will write 1

then numbers should generate from 5.

i tried looping through this

for(fdpaymentjournal = paymentJournalfds.getNext() ; fdpaymentjournal ; fdpaymentjournal = paymentJournalfds.getNext() )
{

}

i tried even get first() and get selection but no luck

Please help me if i select any record that form datasource should loop in my class

please show some light on this.

Regards.

Have a great day.

  • AX 2012 r3 Profile Picture
    AX 2012 r3 2,420 on at
    RE: Loop form datasource

    i am actually generating cheque numbers

    they will provide start number like 100001 then all records will get updated so no need to give cheque numbers and those will get printed in cheque print report.

  • Martin Dráb Profile Picture
    Martin Dráb 228,112 Most Valuable Professional on at
    RE: Loop form datasource

    I'm sorry, but I have no idea what you mean. Please try a bit more elaborate explanation.

  • AX 2012 r3 Profile Picture
    AX 2012 r3 2,420 on at
    RE: Loop form datasource

    "Why do you want to develop a much worse solution".

    I have kept conditions.it will update only if value is not there.

    Once updated wont come into picture again.

  • Martin Dráb Profile Picture
    Martin Dráb 228,112 Most Valuable Professional on at
    RE: Loop form datasource

    Why do you want to develop a much worse solution (several times slower, more work) if you already know how to do it properly? Don't ever use your design; you would meaninglessly fetch all records to client just to send them back to server, which wouldn't make sense.

  • AX 2012 r3 Profile Picture
    AX 2012 r3 2,420 on at
    RE: Loop form datasource

    you are correct updating table i  have already done that.

    I need through form data source is it possible to get records.even my cursor is at last.

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 228,112 Most Valuable Professional on at
    RE: Loop form datasource

    What's the purpose of the field and its update?

    Why do you do it in a form on client at all? Don't you want to update all records in the table, regardless of which ones are currently fetched in the report? If so, you should update the table on server and then merely reload data in the form.

  • AX 2012 r3 Profile Picture
    AX 2012 r3 2,420 on at
    RE: Loop form datasource

    1.i have one form in that i have one field

    2.Created one class which updates that field with continuous number

    3.In that class i will take number to start as parameter

    4.i want to update all the records in form.

    5.when i open the form the cursor is always on top.

    if i change the cursor position and i select 5th record

    if i click that button i am not able to get the first record .

    How can i achieve this.

    Even when cursor position is at last i want to update from starting

    i have searched and i used this

    for(fdpaymentjournal = paymentJournalfds.getNext() ; fdpaymentjournal ; fdpaymentjournal = paymentJournalfds.getNext() )

    {

    }

    But first time it is updating and even if i change position

    But after second time it is not even entering the for loop.

  • Martin Dráb Profile Picture
    Martin Dráb 228,112 Most Valuable Professional on at
    RE: Loop form datasource

    Sorry, it's not clear to me which records you're trying to iterate. Could you please explain the business requirement you're trying to implement?

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,263 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,112 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans