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, ...
Suggested Answer

Why is changecompany() not working?

(0) ShareShare
ReportReport
Posted on by 845
Hello,
In the class where I make the select in CustTable, changecompany() is not working. It stays in the current location all the time.
Can anyone suggest how to apply this correctly?
 
[...]
changecompany(_company)
{
      select firstOnly custTableLocal
          where custTableLocal.AccountNum== _customer;
 
     //some logic
}   
[...]  
 
I have the same question (0)
  • Suggested answer
    Layan Jwei Profile Picture
    8,282 Super User 2026 Season 2 on at
    Hi Shooowtek,

    May I ask how did you know that it is not working?

    Did you try and debug? and see what is the value of _company and custTable.DataAreaId?

    what if the same custAccount exists in different legal entities and you thought it's the same?

    However, if you debugged and found that dataArea values are different then maybe declare CustTable inside changeCompany.

    Thanks,
    Layan Jweihan
  • Suggested answer
    Mohit Rampal Profile Picture
    12,573 Moderator on at
    Hi, You didn't provided the complete code. However, try clearing custTableLocal buffer before select statement. 
     
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at
    The problem is with the table buffer. When you select the table it will carry a buffer. The change company doesn't clear the buffer and will find a value from the previous company which will obviously return empty buffer. So to get the exact buffer either you can clear the table buffer like Mohit suggested or declare the table variable inside the change company.
     
    I mean,
     
    changeCompany('compName')
    {
    Table table;
    select table;
    }

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... 293 Super User 2026 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 260 Most Valuable Professional

#3
Anton Venter Profile Picture

Anton Venter 224 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans