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 :
Finance | Project Operations, Human Resources, ...
Answered

Iterate a table buffer in memory

(0) ShareShare
ReportReport
Posted on by 81

Hi,

I have a class that pulls all the cleared hold codes for a Sales order. For the life cycle of the class, I need to see if a record exists or not. I want to make this call once when the class is instantiated. Once the table buffer has records, I want to know if I can use it as a lookup table? For example, can I iterate over the buffer in memory?

MCRHoldCodeTrans mcrTransTableCleared;

select mcrTransTableCleared
        where mcrTransTableCleared.InventRefId == this.salesOrder.SalesId
        && mcrTransTableCleared.mcrCleared == NoYes::Yes;

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    You normally can't do that (I'll explain an exception at the end). A select statement makes a query into the table; it can't hold the data in memory.

    Nevertheless you could fetch the data and store it in a collection (e.g. RecordSortedList), a temporary table or so. Then you can iterate the collection or even run select statements agains the temporary table.

    But there is one more feature you could use: RecordViewCache. It's a bit cryptic and rarely used, but it could be useful in your case.

    You need to run a select statement with 'noFetch' and then using the the table buffer in the constructor of RecordViewCache class:

    RecordViewCache transTableClearedCache;
    MCRHoldCodeTrans mcrTransTableCleared;
    
    select nofetch mcrTransTableCleared
    	where mcrTransTableCleared.InventRefId == salesOrder.SalesId
    	   && mcrTransTableCleared.mcrCleared == NoYes::Yes;
    	   
    transTableClearedCache = new RecordViewCache(mcrTransTableCleared);	

    Then you can run queries against the buffer (mcrTransTableCleared), which will contain just the records defined by the original select statement.

  • PhillyNJ Profile Picture
    81 on at

    Awesome and thank you!

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 611 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans