Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Copying data from one table buffer to another one without having an underlying reference

(0) ShareShare
ReportReport
Posted on by 240
I have one function in which I want to add 3 rows to an InMemory table buffer and then return it (it is used in a setTempData call to be set as the datasource for a grid)
 
The third row is calculated by differences between the first two rows.
 
I have the following setup:
 
 
 
HourTotals hourTotals;
HourTotals hourTotalsRegistered;
HourTotals hourTotalsPlanned;
 
hourTotals.Maandag = 2;
hourTotals.Hourtype = HourType::Registered;
hourTotals.insert();
 
hourTotalsRegistered.data(hourTotals.data());
hourTotalsRegistered.insert();
select firstonly * from hourTotalsRegistered where hourTotalsRegistered.HourType == HourType::Registered;
 
hourTotals.Maandag = 1;
hourTotals.Hourtype = HourType::Registered;
hourTotals.insert();
 
hourTotalsPlanned.data(hourTotals.data());
hourTotalsPlanned.insert();   
select firstonly * from hourTotalsPlanned where hourTotalsPlanned.HourType == FM_HourType::Planned;
 
hourTotals.Maandag = hourTotalsRegistered.Maandag - hourTotalsPlanned.Maandag;
 
 
 
The last line creates a stackOverFlowException. This is probably the case because the 3 table buffers still refer to each other.
My goal is to store the data of the first two rows in another variable, so I can calculate the third row, also insert it into the original hourTotals buffer and then return it.
 
SECOND TRY:
I also tried replacing the data() calls by using buf2Buf(hourTotals, hourTotalsRegistered), but this gives the same problem.
 
THIRD TRY:
I also tried using insert_recordset, but this also gives the same error at the same line:
            FM_HourTotals hourTotalsPlanned;
            insert_recordset hourTotalsPlanned(Maandag, Dinsdag, Woensdag, Donderdag, Vrijdag, Zaterdag, Zondag, Totaal, HourType)
            select firstonly Maandag, Dinsdag, Woensdag,Donderdag, Vrijdag, Zaterdag, Zondag, Totaal, HourType   
                from hourTotals where hourTotals.HourType == FM_HourType::Planned;
 
How would I go about doing this?
            
 
 
 
  • André Arnaud de Calavon Profile Picture
    292,884 Super User 2025 Season 1 on at
    Copying data from one table buffer to another one without having an underlying reference
    Hi Superbunny,
     
    Can you explain the exact functional requirement? What is the source for the registered and planned hour details? What is the exact error message you get?

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,884 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,760 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans