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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

Query::insert_recordset() with changeCompany not working.

(2) ShareShare
ReportReport
Posted on by 356
Hi,
 
I am using query::insertRecordSet() to the one of the business process requirement.
 
query is inserting always against first company record in the change company loop, eventhough company context is changing, 
 
Reason here is, source table dataareaid column is not resetting, but instead query::insertRecordSet(), if am using insertrecordset means,
each change company iteration, i can reset the table buffer.
 
If am using the query::insertRecordSet(), how to reset the table buffer.
 
the below code always doing insertion against 1200 legal entity only.
 
   public void insertion(Common _target, Map _fieldMapping, Query _query, QueryRun _queryRun)
   {
       changecompany ('1200')
       {
           Query::insert_recordset(_target, _fieldMapping, _query);
       }
       changecompany ('1100')
       {
           Query::insert_recordset(_target, _fieldMapping, _query);
       }
       
   }
I have the same question (0)
  • Jonas "Jones" Melgaard Profile Picture
    5,016 Most Valuable Professional on at
    You will either have to set your _target to null before you insert, or create a new buffer for each company.
  • Martin Dráb Profile Picture
    240,312 Most Valuable Professional on at
    Try assigning null to the buffer (inside the changeCompany block).
  • Vigneshvaran Profile Picture
    356 on at
    Thanks Martin for the reply, inside in the above sample code, which buffer u will assign as null.
     
  • Vigneshvaran Profile Picture
    356 on at
    Thanks Jonas, target also i set as null, but doesn't works.
  • Jonas "Jones" Melgaard Profile Picture
    5,016 Most Valuable Professional on at
    Hmm... that's unexpected....
    Have you tried creating a new buffer for each company call? I can send you some example code if you want.
  • Sagar121 Profile Picture
    1,196 Super User 2026 Season 1 on at
    @Vigneshvaran You can create one more Common _target2 for 1100 Legal entity use _target2 in Query::insertRecordset(_target2, _fieldMapping, query)

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 286 Super User 2026 Season 2

#2
SajeedMullaji Profile Picture

SajeedMullaji 272

#3
Martin Dráb Profile Picture

Martin Dráb 258 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans