AX Feature: Cross Company


Cross company support in forms, reports, queries and X++.

Yes, and it is the same what you are pondering on : you can display records from different companies in a single form (or report). Yeah ..

For a form, you just have to set the property AllowCrossCompany to Yes in the form's query and add a field that displays the company's ID to the forms's grid. That's it. Easy as that!

In X++, there is a new keyword crossCompany you can use in a select statement. Additionally, you can add a container with all the company ID's you want to include in your select statement.

So, your select statement could look like that:


while select salestable crossCompany : [dmo, cos]
{
... do something ...
}

And in query, this is the simplest way to achieve it:

static void CrossCOmpanyExample(Args _args)
{
    Custtable               ct;
    Query                   q;
    QueryRun                qr;
    QueryBuildDataSource    qbds ;
    ;
   q    = new query();
   qbds = q.addDataSource(tablenum(CustTable));

   q.allowCrossCompany(true);
   q.addCompanyRange('axt');
   q.addCompanyRange('dat');

    qr = new QueryRun(q);

    while(qr.next())
    {
        ct = qr.get(tablenum(CustTable));
        info(ct.AccountNum);
    }
}

No comments

Powered by Blogger.