Axaptapedia is now maintained by AgileCadence For more information please click here.

Range

From Axaptapedia
Jump to: navigation, search

see also: Expressions in query ranges


Axapta has a kernel method called rangeCount() which obviously cannot be seen/altered. This method returns the number of ranges in a specific query. I would like to know the coding in this method as Axapta 4 has a bug - it does'nt return the correct number.

This is what i have so far, <xpp> . . . int counter = 1;

while(counterRun = true) {

 _queryBuildRange = _queryBuildDataSource.range(counter);//Line 5
 if(_queryBuildRange.value())
 {
   counter++;
 }
 else
 {
   counterRun = false;
   counter = 0;
 }

} </xpp> This works if there are ranges and if there are none which sounds perfect..however, The bug in Axapta assumes there is a range but when it gets to Line 5 it throws an error - which is correct because its trying to access a range when in actual fact there is none. So does anyone know the coding behind the method rangeCount()? Please could someone HELP.

That's a little bit unsecure code, not Axapta bug. Let say if you have 3 ranges in the query, which all have value, this code will generate an error because the Line 5 still access the range number 4, the reason is when counter = 3 (the max range reached), its value is not empty, so, variable counter will be added 1, then run to the begin of while loop, and make Axapta access to the range 4 ( which not available), this cause error. Let's write another way :

<xpp> int counter = _queryBuildDataSource.rangeCount();

while(counter > 0 ) {

 _queryBuildRange = _queryBuildDataSource.range(counter);//Line 5
 print  _queryBuildRange.value()
 counter--;

} </xpp>

hope this help, Vyd