Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Suggested answer

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 :)

  • 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 225,985 Super User 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 225,985 Super User 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().

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,768 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,985 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans