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

Current Company Language id in Aot Query range value

(0) ShareShare
ReportReport
Posted on by 2,426

Good Evening

As i am trying to apply some range on Aot Query - Language Id - (SysQueryRangeUtil::currentLanguageId())

But this is not working.

How can i apply in range for current company - Language id

Regards,

Have a nice day.

I have the same question (0)
  • AX 2012 r3 Profile Picture
    2,426 on at

    Dear Experts Please reply

  • AX 2012 r3 Profile Picture
    2,426 on at

    Dear Experts any suggestion

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    Your approach is correct, if you want the current session language (not necessarily the company language). I'm just not sure if you can include 'SysQueryRangeUtil::' there, but I guess you can.

    If you need more help, please tell us more about your problem than just that it's not working". Please don't forget about tools that you have at your disposal, e.g. the debugger or the ability to trace SQL commands.

  • André Arnaud de Calavon Profile Picture
    301,075 Super User 2025 Season 2 on at

    Hi AX2012R3,

    Can you tell what exactly you have done and where you did put this statement (what object/method)?

  • WillWU Profile Picture
    22,361 on at

    Hi AX2012 R3,

    Please try this:

    static void main(Args _args)

    {

           info(Companyinfo::languageId());

    }

    Hope this helps.

  • AX 2012 r3 Profile Picture
    2,426 on at

    Hi,

    Requirement - Items Description based on legal entity Language id

    I am using one AOT query where i have inventtable and ecoresproduct and ecoresproducttranslations tables joined

    Now i want to add language id field present in Ecoresproducttranslation to Aot Query range - and the value should be - Company::languageid()

    Current company language id i want to add as value to the AOT Query Range.

    How can i add in AOT Query Range.

    I am using panel

    for left panel i have to show data for that i am using Query and then View and this view i am using as Datasource to Available list panel -

    I cannot use Code here that is the reason i am using AOT Query range value

    Regards,

    Have a nice day.

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    I still miss an explanation of your problem, apart from that "it doesn't work".

    If you don't understand your problem and you have no idea how to debug it, let me give you a few pointers:

    1) Tell us what you see when you execute the query. You get no data, you get the same data as if there wasn't any filter, you get different data than you expect...

    2) Instead of using a method, start with a hard-coded language code. If it doesn't work, you have a problem in your query that isn't related to the method. Fix that first.

    3) If your problem is that currentLanguageId() doesn't give you the value you want, simply create a new method in SysQueryRangeUtil that will return Company::languageId().

  • AX 2012 r3 Profile Picture
    2,426 on at

    No martin

    "I still miss an explanation of your problem, apart from that "it doesn't work""

    This means that range is not applying martin (If hardcoded wrks fine)

    I tested with hardcode in en-US and it works fine.

    and tried by writing this as well

    [ExtensionOf(classStr(SysQueryRangeUtil))]

    final public static class TestSysQueryRangeUtil_Extension

    {

       [QueryRangeFunctionAttribute()]

       public static str  CompanyLanguageId()

       {

           return CompanyInfo::languageId();

       }

    }

    tried using SysQueryRangeUtil::CompanyLanguageId() in AOT Query range Value

    Still the range is not applying

    The reason would be that it will not execute methods like that(Companyinfo::languageid())

    Its better to go with Computed column because i can write some conditions.

    Can i get some example of Condition based view computed columns as per coding standards to D365fo

    Regards,

  • WillWU Profile Picture
    22,361 on at

    Hi partner,

    You can add a range to the AOT query within X++,

    Query query;

    QueryRun qr;

    QueryBuildDataSource qbd;

    query = new Query();

    qbd = query.addDataSource(tablenum(EcoResProductTranslation));

    qbd.addRange(fieldNum(EcoResProductTranslation,LanguageId)).value(CompanyInfo::languageId());

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    Have you tried it just (currentLanguageId()) instead of  (SysQueryRangeUtil::currentLanguageId())? I mention in the first reply that I wasn't sure if what you did would work.

    CompanyInfo::languageId() is just wrong - you can't use any method for filtering.

    If you want to create your own method for filtering, don't create an extension of SysQueryRangeUtil. Create a separate class and merely decorate the method with QueryRangeFunctionAttribute. Then you must use your class name when calling the method.

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 592 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 478 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 305 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans