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

Why is changecompany() not working?

(0) ShareShare
ReportReport
Posted on by 843
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,112 Super User 2025 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,565 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

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 646 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