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

Notifications

Announcements

No record found.

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,284 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,284 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans