create a new row in table through dialog and automatically select it after dialog window is closed (Dynamics 365 F&O)

Hello,

It would be nice if someone could help me and share some ideas/code on how to automatically select the row in a table created from a dialog window. At the moment the code just updates the table and inserts the new row, but automatically selects the first row of the table.

Best regards,

Roberts

If the new record will be at the end, maybe it’s sufficient always going to the last record instead of the first.

If you must find the record somewhere in a grid, you can use positionToRecord() of the form data source.

Yes, going to last record would work. How to achieve that?

K, I have written a code like this, at the moment it shows the last record Id, could you provide example on how to select the record based on it. Code is as follows:

public void select_last()

{

EBGateEntry ebGateEntry;

select LoadId from ebGateEntry order by LoadId desc;

info(strFmt("%1",ebGateEntry.LoadId));

}

Open properties of your form data source and change Start Position from First to Last.

Thanks for your help, I will verify your answer. However, I found that just changing the position will not work. I need to update the function and use ebGateEntry.LoadId as an argument to select the appropriate row. Any help would be appreciated. Anyway, thank you!