0

Anyone have sample lookup code for AOT objects? (or know where to find the one they use for the AX properties window)

I need to replicate the functionality that you see in several fields in the properties window. The ExtendedDataType field is a good example. Type a few letters, hit the down arrow, and a filtered list of AOT ExtendedDataType objects appears.

I've been trying to use treeNode findChildren to build my custom lookup list, but it is very slow. Whatever method AX is using happens instantly.

Thanks

Brad
  • 1,357
  • 5
  • 33
  • 65

2 Answers2

1

Try this:

Dictionary d = new Dictionary();
int i;
int cnt = d.tableCnt();
TableId tableId;
str nameForLookup;

for (i = 1; i <= cnt; i++)
{
    tableId = d.tablecnt2id(i);
    nameForLookup = tableid2name(tableId);
}

Queries to the Model/Util*Element tables will not be cached, and are relatively slow due to the number of records that they contain.

There may be other factors slowing down execution as well. If you are on 2012, for lookups, you may want to build a temp table with an XDS() method, which populates itself using the above code, then you can simply select from that table (and it will be cached for the session):

  1. create a SQL Temp table (e.g. with a name like MyTableLookup), add a name column
  2. add a method like this:

    public RefreshFrequency XDS()

    {

    MyTableLookup tableLookup;
    
    ttsbegin;
    // Use the above code to insert records into tableLookup
    ttscommit;
    
    return RefreshFrequency::PerSession;
    

    }

  3. bind your form to MyLookupTable

jhlange
  • 48
  • 4
  • This worked great. Takes about a second and a half to bring in all class names, which is completely acceptable. – Brad Sep 04 '13 at 15:30
0

You may develop an estándar EDT linked to the UtilElement Table properly filtered. This will show a list of objects and will have same functionality of all table-linked text fields.

j.a.estevan
  • 3,057
  • 18
  • 32
  • Maybe I went about this wrong, but I created a filtered lookup against the UtilElement table for this field, even with filters applied. It seems to be just as slow. About 5 mins after you click the arrow, the dropdown appears. If you've had good luck with this, do you mind posting step-by-step instructions? Thanks – Brad Apr 14 '13 at 21:29
  • It's not your fault, this table works very slow all the time. It's a metadata table and it's not as eficient as SQL tables, but usualy is only used for setup processes and this performance issue is not a big deal. Anyway, 5 minutes seems a lot. This may be caused for the client refreshing the cache each time, may be on a development environment where AOS restarts many times... – j.a.estevan Apr 15 '13 at 08:31
  • It seems there should be a better way. The AX Client does a lookup like this all the time with no delay. – Brad Apr 15 '13 at 18:26