Dev tip: Finding if a range is specified in a query – Dynamics Ax
Here is a simple tip.
Recently i had a requirement which wanted to validate if a range has been entered in a query. The obvious approach would be running through the ranges in the query data sources and verify if each of them has a range. When you have multiple data source this is obviously not an interesting way to solve it and can be fooled around by just entering a value like ‘*’. So i was thinking out on a better approach and luckily i seemed to find it. Here it goes, the idea is to get the count of the records through the Query and get the count of the records directly through a DML, when compared if they are equal then there is no range entered.
InventTable inventTable; int cntTotal; ; cntTotal = SysQuery::countTotal(gQueryRun); select count(recid) from inventTable; if (inventTable.RecId == cntTotal) { throw error('Atleast one range must be specified for the item selection.'); }
Where can this be used ?
You can put it to use to prevent long running reports http://bit.ly/1bzGHVE to ensure that there are proper ranges.
Related articles
- Dev Tip: Finding test data across companies – Dynamics Ax (kamalblogs.wordpress.com)
- Get look-up data based on other lookup in c# from two tables. (axchaitu.wordpress.com)
-
September 9, 2013 at 8:17 amSSRS tip: No row message in Dynamics Ax SSRS 2012 - Casperkamal’s Dynamics AX Blog - Microsoft Dynamics AX - Microsoft Dynamics Community
-
September 9, 2013 at 7:46 amSSRS tip: No row message in Dynamics Ax SSRS 2012 | Casperkamal's Dynamics Ax blog