Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

locate the current cursor of a table.

Posted on by Microsoft Employee

Hello.

I am using QueryBuildDataSource.

How can I locate the current cursor, if I know what is the exact key (Using QueryBuildDataSource) ?

Thanks :)

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    Re: locate the current cursor of a table.

    Found.

    This is a simple solution, that I could find at your answer this one.

    just put on "ExecuteQuery" method of datasource the lines :

    MyRefTable = element.args().record();

    MyTable_ds.findValue(fieldNum(MyTable, MyColumn), MyRefTable.MyRefColumn);

    (MyRefTable.MyRefColumn has the appropiate value that I should focus on the new table).

    Thanks, anyway :)

  • Martin Dráb Profile Picture
    Martin Dráb 230,214 Most Valuable Professional on at
    Re: locate the current cursor of a table.

    I see that the question was probably answered, anyway I'll post my answer too, because the question may not to be actually about cursors at all. :-)

    GPaperLookup is not a standard form. I'll assume that packagingGrid is a FormGridControl. In that case, don't try to get value from the grid, use rather its underlaying data source. If it GPaperTable is the corresponding data source, you have two (basic) possibilities:

    For single-selection scenarios, get the value directly from GPaperTable variable.

    For multi-selections, the easiest way would be something like this:

    GPaperTable paperTable;
    MultiselectionHelper selection = new MultiselectionHelper();
    selection.parmDatasource(GPaperTable_ds);
    paperTable = selection.getFirst();
    while (paperTable)
    {
    //do something
    paperTable = selection.getNext();
    }
  • Luegisdorf Profile Picture
    Luegisdorf 1,930 on at
    Re: locate the current cursor of a table.

    The cursor on the grid equals the cursor to the form data source which represents the data provider for the grid.

    Just take the name of the data source and add underscore & 'ds' to access the form data source. The cursor is retrieved by the method cursor().

    Example:

    myEmplTableBuffer = emplTable_ds.cursor();

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    Re: locate the current cursor of a table.

    OK.

    There is a grid component (I don't know if it is global to Microsoft Dynamic AX.

    Specificaly on : GPaperLookup, GPaperTable init event. The packagingGrid component).

    How can I locate the cursor on the grid component?

    Thanks :)

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,214 Most Valuable Professional on at
    Re: locate the current cursor of a table.

    QueryBuildDataSource is a query specification only, it doesn't fetch any data.

    If you are using QueryRun, you can obtain current record by calling get(yourTableId).

    If you are on a form, you can also use FormDataSource.cursor().

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

Featured topics

Product updates

Dynamics 365 release plans