AX – D365FO – Unable to to Add/Update the Data Source on a ListPage in Microsoft Dynamics AX 2012

You CANNOT drag and drop a data source into a list page.  This is different than most forms, so it always stumps me! Instead, right click on the ‘Data Sources’ node within the form.  The query property sets the data source. If you’ve modified the query and would like to refresh it, you must change the … Continua a leggere AX – D365FO – Unable to to Add/Update the Data Source on a ListPage in Microsoft Dynamics AX 2012

AX – D365FO – X++ – Retrieve multiple occurrences of a DataSource in a QueryBuilDer with dataSourceTable method

When you make a query it can happen that you use more than one data source for the same table. If you use the query builder you will have to set the filters on the right data source. If you have multiple data sources for the same table the only way to select the correct … Continua a leggere AX – D365FO – X++ – Retrieve multiple occurrences of a DataSource in a QueryBuilDer with dataSourceTable method

AX – D365FO – Advanced filtering in code X++ on Query object

So, you are creating the query programmatically (of course using the Query* classes), and you need a statement like select * from tableA where columnB = val1 or columnC = val2 just do it like:     QueryBuildDataSource    qbds;     QueryBuildRange             qbr;    str                                      range;     // initializing the query and the datasource(s) here; will go like qbds = … Continua a leggere AX – D365FO – Advanced filtering in code X++ on Query object

AX – D365FO – Advanced filtering and query syntax

Advanced filtering and query syntax You are a Dynamics 365 Finance system administrator.Data must be filtered based on given criteria to help users quickly reduce the number of records.You need to identify the appropriate syntax to solve user requirements This topic describes the filtering and query options that are available when you use the Advanced … Continua a leggere AX – D365FO – Advanced filtering and query syntax

AX – D365FO – Avoids deleting a record if it has records related to other tables (with table Relations functionality)

If you want to avoid deleting record on a table that has child record related to other table just follow this instructions. You must create a relation between Table "Al0VendorActivity" and "Al0VendorSearcCriteria". We want to avoid delete record from "Al0VendorActivity" if at least one record exists in the table "Al0VendorSearcCriteria". Create a relation between the … Continua a leggere AX – D365FO – Avoids deleting a record if it has records related to other tables (with table Relations functionality)

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

AX – D365FO – Get current data source record

If you want to get the current selected data source record you can use dataSource_ds.cursor() method See code below public void executeQuery() { super(); if(Al0VendorActivity_ds.cursor().RecId != 0) { QueryBuildDataSource productCategory_ds = this.query().dataSourceTable(tableNum(Al0VendorSearchCriteria)); productCategory_ds.addRange(FieldNum(Al0VendorSearchCriteria, VendorActivityRefRecId)).value(int642Str(Al0VendorActivity_ds.cursor().RecId)); } }

AX – D365FO – Clear a value of a previously query set filter

If you have done a query in a form and you you want to clean previouslu query filter you have to follo w this code public void executeQuery() { // Get the filter value from the filter control. date firstYearOfMonth; str monthStr; str yearStr; MonthsOfYear monthEnum; int monthEnumToInt; TransDate tmpDate; TransDate dateInMonth; TransDate firstDateOfMonth; TransDate … Continua a leggere AX – D365FO – Clear a value of a previously query set filter

AX – D365FO – Multiple Aggregations in X++ Join (Group by, SQL)

CustInvoiceJour custInvoiceJour; CustInvoiceTrans custInvoiceTrans1; CustInvoiceTrans custInvoiceTrans2; while select InvoiceAccount,InvoiceId from custInvoiceJour group by InvoiceAccount outer join InvoiceId, sum(LineAmount) from custInvoiceTrans1 where custInvoiceJour.InvoiceId == custInvoiceTrans1.InvoiceId && custInvoiceTrans1.InvoiceDate >= str2DateDMY(‘1.1.2011′) && custInvoiceTrans1.InvoiceDate <= str2DateDMY(‘31.12.2011′) outer join InvoiceId, sum(LineAmount) from custInvoiceTrans2 where custInvoiceJour.InvoiceId == custInvoiceTrans2.InvoiceId && custInvoiceTrans2.InvoiceDate >= str2DateDMY(‘1.1.2012′) && custInvoiceTrans2.InvoiceDate <= str2DateDMY(‘31.12.2012′) { info( strFmt("Customer:%1 2011:%2 2012:%3", … Continua a leggere AX – D365FO – Multiple Aggregations in X++ Join (Group by, SQL)