Skip to main content

Posts

Showing posts with the label research

Tutorial: refresh, reread, research, executeQuery - which one to use?

X++ developers seem to be having a lot of trouble with these 4 datasource methods, no matter how senior they are in AX. So I decided to make a small hands-on tutorial, demonstrating the common usage scenario for each of the methods. I have ordered the methods based on the impact on the rows being displayed in the grid. You can download the xpo with the tutorial on my SkyDrive. 1. Common mistakes Often, developers call 2 of the mentioned methods in the following order: formDataSource.refresh() formDataSource.research() or formDataSource.reread() formDataSource.research() or formDataSource.research() formDataSource.executeQuery() or formDataSource.research() formDataSource.refresh() / formDataSource.reread() All of these are wrong, or at least partially redundant. Hopefully, after reading the full post, there will be no questions as to why they are wrong. Leave a comment to this post if one of them is still unclear, and I will try to explain in more detail. 2. Refresh This method basical...

Research method on X++ forms

In AX2009 if you call the research() method on a form passing true, the cursor position within a grid should be retained. However, this is true only if the query created by the form uses inner joins. Any outer joins, aggregations, temp tables, etc. cause the cursor to go to either the first or last record (depending upon the StartPosition property for that data source). In 2009 if you want to keep the cursor position and use joins other than inner joins you have to keep track of the cursor position. Code like the following will do this: int pos; super(); pos = salesQuotationTable_ds.getPosition(); salesQuotationTable_ds.research(); salesQuotationTable_ds.setPosition(pos);