web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Custom lookup using an InMemory table with Insert_Recordset

(0) ShareShare
ReportReport
Posted on by

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();
}

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Mea_ Profile Picture
    60,286 on at

    Hi Brawndo,

    Please try to add

    select myInMemoryLookupTmp;


    line after

    insert_recordset myInMemoryLookupTmp (ProjId)   // note - my inMemory table is declared in the form's class declaration
     select ProjId 
     from projTable;


    to initialize a buffer, otherwise it's empty and you are doing lookup against empty buffer.

  • Greg's Mom Profile Picture
    on at

    Thanks, Ievgen!  I'll give it a shot!

  • Mea_ Profile Picture
    60,286 on at

    Hi Brawndo,

    If your question is solved could you please mark any answer(s) that helped you as verified to close this thread ?

  • Greg's Mom Profile Picture
    on at

    Sorry for not marking the answer sooner and thanks again for the helpful feedback!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Andrew Jones a1x Profile Picture

Andrew Jones a1x 2

#3
GL-01081504-0 Profile Picture

GL-01081504-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans