Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Suggested answer

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

Posted on by Microsoft Employee

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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to achieve Filtering of the Company Range in AOT Report.

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

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to achieve Filtering of the Company Range in AOT Report.

    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
    Community Member Microsoft Employee on at
    RE: How to achieve Filtering of the Company Range in AOT Report.

    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
    Community Member Microsoft Employee on at
    RE: How to achieve Filtering of the Company Range in AOT Report.

    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
    Community Member Microsoft Employee on at
    RE: How to achieve Filtering of the Company Range in AOT Report.

    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
    Community Member Microsoft Employee on at
    RE: How to achieve Filtering of the Company Range in AOT Report.

    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
    Community Member Microsoft Employee on at
    RE: How to achieve Filtering of the Company Range in AOT Report.

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

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,986 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,588 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans