Other recent Dynamics AX Blog postings

Donnerstag, Dezember 08, 2005

Slow ZipCodeLookup

If you have lots of zipcodes in your Zipcode table, you will get the problem that when you click on the lookup button of your zipcode field and it happens that the content of the zipcode field is one of the last records in your table, you will have to wait and wait and wait...

Reason: in the form ZipCodeLookup, method "run", the standard system uses the function "findrecord". Findrecord will go through the table and compare each record with the one you search! This is the same as if you would go down the form clicking each record.

The sad thing is: there's not much you can do about it. The only thing I thound was to replace the findrecord method with a filter.

Advantage: the lookup will show up immediately.
Disadvantage: the lookup form will only show records that match the zipcode from the previous form. Here's what you have to change in the method:

if (zipCodeCurrent)
//zipCode_ds.findRecord(zipCodeCurrent); // Ori
// Replace original line above with next line
zipCode_ds.query().dataSourceTable(tableNum(ZipCode)).addRange(fieldNum(ZipCode, ZipCode)).value(zipcodecurrent.ZipCode+".."); zipCode_ds.executeQuery();

Give it a try! And tell me what you think about it!

3 Kommentare:

Johan V hat gesagt…

I´ve got this problem for quite some time...
I´ll give it a try!

Johan hat gesagt…

It works fine thx!

Anonym hat gesagt…

In 4.0 we have implemented both solutions. In some installations the speed of findRecord won't be a problem because you have a limited number of zipcodes, but in others it is way to slow.

What we are doing in 4.0 is that we start out using the findRecord approach, but we meassure how long it takes to show the lookup. If it takes more than 2000 Miliseconds we switch strategy to use the filter. We store the choosen strategy in SysLastValue.

Best Regards,
Palle Agermark

This posting is provided "AS IS" with no warranties, and confers no rights.