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)

InMemory table as datasource in the form could not read existing records on Initvalue() method.

(0) ShareShare
ReportReport
Posted on by

Hello,

I have a simple form  where it has a  table (In Memory) as a datasource.

On page load, I m filling this table from data coming from web services on the fly. 

Once page gets loaded, User adds a new record in it. For each line user adds, i want to assign the new Line num which would be in addition to the max linenum out of the record i got from the web service records.

Hence in Initvalue() method of table, I am trying to find the max linenum from the existing record but I always get 0 records. not sure why.  User could see the records came from the web service on the form. They can add the new record as well but LineNum is not getting set correctly for these new records. ALL newly added records gets LineNum=1 because it thinks that there is no any record in the table.

Table's initvalue method is shown below.

public void initValue()
{

MyTempTable  tmp;

super();

select maxOf(LineNum) from tmp;
this.LineNum = tmp.LineNum +1;
 
}

Can someone help to identify what's missing?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Brandon Wiese Profile Picture
    17,788 on at

    Temporary tables, both memory and tempdb, are not backed by single instance table like regular AOT tables.  With regular AOT tables, like CustTable, when you declare a variable of type CustTable, it is ultimately backed by the same physical database table.  You can select and filter on your variable, creating a result set (or subset), and move next and such, acting as a cursor, but all variables of type CustTable share a common backing table.

    Each time you instance a temporary table, as you have done in your declarations in initValue(), it is backed by a separate data set.  So in your initValue() method when you declare MyTempTable tmp; that is not the same backing table as the record referenced by "this".

    Fortunately, you can connect your new variable to the backing table of "this".  I believe the following line works (it is different for in memory and tempdb tables).

    tmp.setTmpData(this);

    Hope this helps.

  • Community Member Profile Picture
    on at

    I already tried this but somehow forgot to mention in my question.  Sorry that doesn't work.

  • Mea_ Profile Picture
    60,286 on at

    setTmpData should actually work, could you please share your code, so we can advise if something wrong there.

  • Verified answer
    Community Member Profile Picture
    on at

    Instead of writing code in initvalue() of table, i wrote it on initvalue() of form datasource and it worked. I wrote it before super() call in it.

    public void initValue()

    {

    MyTempTable  tmp;

    tmp.settmpData(MyTempTable);  // Here MyTempTable is a datasource.

    select maxOf(LineNum) from tmp;

    this.LineNum = tmp.LineNum +1;

    super();

    }

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Sagar Suman Profile Picture

Sagar Suman 2 Super User 2026 Season 1

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans