AX – D365FO – Change data in calling datasource

formDataSource formDataSource; formRun formRun; salesTable salesTable; int i; // Change data in calling datasource if(element.args() && element.args().caller() && element.args().caller().handle() == className2Id('formRun')) { formRun = element.args().caller(); for (i = 0; i <= formRun.dataSourceCount(); i++) { formDataSource = formRun.datasource(i); if (formDataSource && formDataSource.table() == tablenum(salesTable)) // Search for specific table { salesTable = formDataSource.cursor(); break; } } … Continua a leggere AX – D365FO – Change data in calling datasource

AX – D365FO – Detect selected line (row) changed in FormGridControl

To detect selected line just use form data sources. Override active() method of the date source - it's executed when a user switches to another record. The active record is in the automatic variable with same name as the data source. Here is an example public int active() { int ret; ret = super(); if (ret) { … Continua a leggere AX – D365FO – Detect selected line (row) changed in FormGridControl

AX – D365FO – Loop through record from data source

/////////////////////////////////////////////// Using a while loop SalesLine localSalesLine; localSalesLine = salesLine_ds.getFirst(true) as SalesLine; if (localSalesLine) { while (localSalesLine) { //Do your thing localSalesLine = salesLine_ds.getNext() as SalesLine; } } /////////////////////////////////////////////// Using a for loop SalesLine localSalesLine; for (localSalesLine = salesLine_ds.getFirst(true) ? salesLine_ds.getFirst(true) : salesLine_ds.cursor(); localSalesLine; localSalesLine = salesLine_ds.getNext()) { //Do your thing }

AX – D365FO – Clear data source query ranges

If you add a query range with a certain value to a Query, then next time you execute the query with another value the query doesn't clear previous range. In order to clean the old values you have to use clearRanges() method see example below /// </summary> public void executeQuery() { super(); QueryBuildDataSource productCategory_ds = … Continua a leggere AX – D365FO – Clear data source query ranges

D365FFO – AX – X++ – Refresh DataSource and retain position

Refresh a DataSource is a very common task to Dynamics AX developers, as you'll most likely perform changes on a record and have to present it to the user, on a form. The most commonly used method to refresh the DataSource to make a form show what you have changed on a record is the research method.The … Continua a leggere D365FFO – AX – X++ – Refresh DataSource and retain position

D365FO – AX – X++ – 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 … Continua a leggere D365FO – AX – X++ – Tutorial: refresh, reread, research, executeQuery – which one to use?