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 :
Microsoft Dynamics AX (Archived)

How to achieve Filtering of the Company Range in AOT Report.

(0) ShareShare
ReportReport
Posted on by

Hi Experts,

I am trying to do a cross company report where i need to filter and show only needed(given) companies in Company range.I have achieved this using following code in AOT Query(used in report) method's.I have  also attached the screen shot for the same.(My system has 100's of companies but i am showing only 4 companies in the result

container getCompanyRange()

{

return [["USMF", true],["BRRT", true],["BRSI", true],["CNMF", true]];

}

Image2send2.png

Now my problem is when i select companies from here using select check box it is not filtering out data correctly in report.Always it return's Data for the 4 companies i selected..Pls help me how to overcome this problem and where i need to customize to solve this issue..

Regards

Varun Gowrishankar

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    I have achieved filtering by of the companies by following code in report or queries

    this.query().allowCrossCompany(true);

    this.query().addCompanyRange("111");

    this.query().addCompanyRange("016");

    this.query().addCompanyRange("291");

    this.query().addCompanyRange("303");

    this.query().addCompanyRange("407");

    this.query().addCompanyRange("014");

    My getCompanyRange() method is not affecting my code..

  • Suggested answer
    Community Member Profile Picture
    on at

    assign all your required legal entity as a container. See the sample code below where i assigned some legal entities in getLegEntity container.

    (you can assign value statically or else get from form or dialog as ur requirement dynamically)

    newquery refers to your query.

    for (counter = 1; counter <= conLen(getLegEntity); counter++)

       {

           curCompanyName = conPeek(getLegEntity,counter);

           changeCompany(curCompanyName)

           {

               newQuery.allowCrossCompany(true);

               newQuery.addCompanyRange(curCompanyName);

           }

       }

  • Community Member Profile Picture
    on at

    Hi Arun,

    I have tried this like code below

    qbds    =   qry.dataSourceTable(TableNum(CustInvoiceTrans));

       for(i = 1; i <= conlen(getingCrossCompanyValue);i++)

       {

           onlyCompany =   conpeek(getingCrossCompanyValue,i);//);

           if(conpeek(onlyCompany,2) == true)

       {

           qry.addCompanyRange(strfmt("%1",conpeek(onlyCompany,1)));

       }

       }

       qr      =   new QueryRun(qry);

       while (qr.next())

       {

           CustInvoiceTrans_1 =  qr.get(TableNum(CustInvoiceTrans));

           this.send(CustInvoiceTrans_1);

       }

    But my problem is onlyCompany Container CONTAINS always true as boolean (which is set in getCompanyRange() method ) even when i deselect the company in query Dialog.

  • Suggested answer
    Community Member Profile Picture
    on at

    Then don't pass it as 'True' for all the companies you have mentioned on the method. Let me know if it solves.

  • Community Member Profile Picture
    on at

    Passing True or False is compulsory in that method like i have used below

    container getCompanyRange()

    {

    return [["USMF", true],["BRRT", true],["BRSI", true],["CNMF", true]];

    }

    .If i solve, i surely will let you know

  • Suggested answer
    Community Member Profile Picture
    on at

    Try this :) I don't find any issue by doing this.

    container getCompanyRange()

    {

          return ["USMF", "BRRT","BRSI", "CNMF"];

    }

    As per my understanding, when u pass all as true, while running query dialog. if u deselect also it will be set as true only because u are passing all the values as True :)

    Check this or elaborate me much better on this, so that i can coordinate with you further to resolve this.

  • Community Member Profile Picture
    on at

    The issue is actually that method(GetCompanyrange) is not dynamically changed according to the values in the Company range tab, for example..if we pass like you told company value's are always false..so nothing is selected each time in fetch method.IF we Pass "TRUE",always true will be selected in fetch 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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 16

#2
Nagendra Varma K Profile Picture

Nagendra Varma K 4

#2
Harisgillani Profile Picture

Harisgillani 4

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans