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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Retain Position On next record on Form

(0) ShareShare
ReportReport
Posted on by 4,624

Hi ,

As i know many ways to retain position on form but now the case is different. In my case , I am transferring lines from Form1 to Form 2. So i wrote code on Form1 (Button Clicked method) . At the end of the code , i have written like this :

Line1 :          Form2_ds.research(true);   // to view the  records on form2 those are transferred. Line2:          form1_ds.next() ;               // to get the cursor on next record on current form

 but when lines get transferred , cursor goes to first record of Form1 instead of next record. 

Note: when i comment "Line1" the cursor comes on next record but i am not able to see transferred record on form2.

 looking for your suggestion.

Thanks

Visvash Walia

*This post is locked for comments

I have the same question (0)
  • Rohin Profile Picture
    4,624 on at
    RE: Retain Position On next record on Form in Ax 2012R2

    Can i get help please ?

  • Rohin Profile Picture
    4,624 on at
    RE: Retain Position On next record on Form

    Hi Martin Dráb,

    can  you please tell what you haven't clear so i will elaborate ?

  • Suggested answer
    Ivan (Vanya) Kashperuk Profile Picture
    on at
    RE: Retain Position On next record on Form

    My guess based on you commenting out Line1 and the position moving correctly

    Can it be that you have a dynalink between the two forms? So depending on which record is selected in Form1, only corresponding records are shown in Form2?

    Have you tried swapping the Line1 and Line2 statements?

  • Rohin Profile Picture
    4,624 on at
    RE: Retain Position On next record on Form

    Hi Iven,

    1.  yes , if i comment Line1 , cursor moves to next record on Form1 but problem is then records are not shown on Form2 those are transferred.

    2. I have button on Form2 which has clicked method to open Form1 using Args class.

    3. I have tried by swapping line 1 and line 2 but not works . It shows records on Form2 but cursor moves to 1st records on Form1.

    looking for your further suggestion

  • Martin Dráb Profile Picture
    236,394 Most Valuable Professional on at
    RE: Retain Position On next record on Form

    Can you show us your complete code, please?

  • Rohin Profile Picture
    4,624 on at
    RE: Retain Position On next record on Form

    yes sure  . please find below code on Form1 :

    code-on-Form2.PNG

    code1-on-Form1.PNG

    code2-on-form1.PNG

    Please find below code on Form2 to open Form1 :

    code-on-Form2.PNG

    Thanks

  • Martin Dráb Profile Picture
    236,394 Most Valuable Professional on at
    RE: Retain Position On next record on Form

    Can you tell us what you think your code does?

    Why do you research a datasource for a different table (CustInvoiceTable) than where you inserted the data (CustInvoiceLine)?

    A few remarks about your code:

    • Business logic such as includeTrans() shouldn't be implemented on forms. Yo
    • Consider validating records before inserting them to database.
    • To get selected records, you can use the MultiSelectionHelper class.
  • Suggested answer
    Ivan (Vanya) Kashperuk Profile Picture
    on at
    RE: Retain Position On next record on Form

    So if I got it right from the screenshots, you are calling research() on the parent form data source.

    Meaning it will always reset the position of the record in your child data source. That's expected.

    Maybe you want to replace the research with

    formDataSource.reread();

    formDataSource.refresh();

    LocalDataSource_ds.next();

    instead

    That might work better for you

  • Rohin Profile Picture
    4,624 on at
    RE: Retain Position On next record on Form

    Hello Ivan,

    I replaced my code with your code :

    formDataSource.reread();

    formDataSource.refresh();

    LocalDataSource_ds.next();

    Now cursor goes to next record on form1 , thats perfect but record are not shown to form2 and when i press F5 on form2 manually then records are visible.  

    looking for your suggestion further please

    Thanks

  • Rohin Profile Picture
    4,624 on at
    RE: Retain Position On next record on Form

    Hi Martin,

    1. My code transfer lines to FreeTextInvoice Form (on InvoiceLines ) from legerSettlement Form.

    2. FreetextInvoice has two datasource : CustInvoiceTable and CustInvoiceLine. And i have used research() to view the transferred record on  FreetextInvoice(InvoiceLines).

    3. I am adopting the Microsoft Dynamics AX Standard code , ledgerSettlement Form has includetrans() methos on form. Please can you tell me the other way where i can write code ?

    4. do i need to call validate method before inserting record ? can you please explore your point .

    looking for your suggestion further please.

    Thanks.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#3
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans