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)

currentCompany is not working on a range value

(0) ShareShare
ReportReport
Posted on by 1,875

Hi.

I have a query with GeneralJournalAccountEntry and GeneralJournalEntry tables, both have the data Shared (SaveDataPerCompany = false).

I've tried to create a view using a query filtering by SubLedgerVoucherDataAreaId field with currentCompany. (CurrentCompany is a standard value from sysQueryRangeUtil class)

25078.1.png

But when I execute the view seem like it show the last execution.

5287.2.png

I delete usage data but It doesn't work, looks like  if I restart Axapta works fine but at the moment I change company the view show information of the last company.

I've tried to delete usage data before start the form but It doesn't work.

private void deleteSysLastValue()
{
SysLastValue sysLastValue;

/* delete_from sysLastValue
where sysLastValue.userId == curUserId()
&& (sysLastValue.elementName like "LedgerGeneralAccountJournalEntry*"
|| sysLastValue.elementName like 'GeneralAccountJournal*');*/

boolean lock = element.lockWindowUpdate(true);

element.design().resetUserSetting();
element.resetSize();
element.arrange();

if (lock)
{
element.lockWindowUpdate(false);
}
}

any idea?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    239,040 Most Valuable Professional on at

    The function works all right, but you're using it the wrong context. If you execute the query, you'll see it works fine. It's the view that doesn't work as you hope, because it can't work like that.

    The view is basically a piece of SQL code and can't call SysQueryRangeUtil class in Dynamics AX. Therefore the method is evaluated on DB synchronization and a fixed DataAreaId is put into the view definition in SQL Server. You can open the definition in SQL Server Management Studio to see if yourself (it's a valuable technique for debugging of views).

  • Verified answer
    André Arnaud de Calavon Profile Picture
    303,730 Super User 2026 Season 1 on at

    Hi Javier,

    In addition, I would like to mention that the field SubledgerVoucherDataAreaId is not the correct field to get all company related transactions. It is filled depending on settings and functionality used. The field Ledger is intended to do the real distinction of legal entities.

  • XB Profile Picture
    1,875 on at

    Both are right.

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#2
Henrik Nordlöf Profile Picture

Henrik Nordlöf 2 User Group Leader

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans