Filter on grid - and then export to Excel with X++

Hi!

I need to filter data on my grid and then create X++ code to export the selected records to Excel. The filter and the X++ code is ok, exept that I don’t know how to fetch only the records from my filter in the grid. Can anyone give me a hint?

I would create a menu item button calling some processing class and I would pass the form datasource into it. Then you can take the datasource instance from the input buffer:

//TODO validate input
FormDataSource ds = _args.record().datasource();

Then extract query from ds.queryRun() (it includes user-defined ranges) and iterate records in your own QueryRun instance.

Thanks a lot.