Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Loop form datasource

(0) ShareShare
ReportReport
Posted on by 2,426

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.

*This post is locked for comments

  • AX 2012 r3 Profile Picture
    2,426 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
    234,100 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
    2,426 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
    234,100 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
    2,426 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
    234,100 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
    2,426 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
    234,100 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?

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 100 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 50

#3
shanawaz davood basha Profile Picture

shanawaz davood basha 6

Featured topics

Product updates

Dynamics 365 release plans