Hello,
I'm trying to create a custom lookup in AX 2012 R2 using an InMemory table. I found that the lookup works if I insert records into my InMemory table one-by-one but if I try using Insert_Recordset, then the lookup does not display anything. I have confirmed by looping through the table and displaying values in the infolog that there are records in the table after using Insert_Recordset, however they do not display in the lookup. Anyone have an idea of what I'm doing wrong or is this just a strange quirk/limitation in AX 2012? Here's what my code looks like for the lookup (P.S. please don't focus on the fact that the sample code is only looking up Project IDs. I could do this with a query without using a temporary table. This is just an example for a proof of concept). Thanks in advance for any ideas on this topic!
public void lookup()
{
ProjTable projTable;
SysTableLookup projLookup;
Query query = new Query();
QueryBuildDataSource qbds;
// try inserting project ids into my inMemory table
insert_recordset myInMemoryLookupTmp (ProjId) // note - my inMemory table is declared in the form's class declaration
select ProjId
from projTable;
/*
if i loop through myInMemoryLookupTmp using while select, I can see all of the project ids have been inserted into the table but nothing displays in the lookup
*/
// If insert records into my inMemory table one at a time like this, the records do display in the lookup...
/*
myInMemoryLookupTmp.ProjId = '100-2000';
myInMemoryLookupTmp.insert();
*/
projLookup = SysTableLookup::newParameters(tableNum(MyInMemoryLookupTmp), this);
projLookup.addLookupfield(fieldNum(MyInMemoryLookupTmp, ProjId), true);
qbds = query.addDataSource(tableNum(MyInMemoryLookupTmp));
projLookup.parmQuery(query);
projLookup.parmTmpBuffer(myInMemoryLookupTmp);
projLookup.performFormLookup();
}