Cross company reports [AllowCrossCompany] in Dynamics AX , X++

This report example will help you to get the data from selected companies or all companies using AllowCrossCompany property

In the AOT, query node objects have the AllowCrossCompany property listed in the Properties window. For new queries the default value is No (which is equivalent to false in X++ code). To make a query cross-company you need to set AllowCrossCompany to Yes.

The classes QueryRun and Query both have the AllowCrossCompany property, but their values always equal each other. When you read AllowCrossCompany from QueryRun, QueryRun reads it from Query. When you set AllowCrossCompany on QueryRun, it sets in on Query.

Please follow me to get the report from multiple companies as shown below.

Right click on AOT >> Reports and Create a new report by name “SR_CrossCompanyItems” as shown below

Expand the datasources and add InventTable as datasource.

On the Query Node, right click and go to property and set the AllowCrossCompany peroperty to “Yes” as shown below.

Expand the design and add Body control to it . Add three fields [ItemId, ItemName and DataAreaId] from the InventTable datasources [Drag- Drop] as shown below

Right click on the report and open the report

Select the print medium as screen and below is the output

If you want to restrict the report to only selected companies data , override the report init() method and add the following code in the init() method

public void init()
{
super();

this.query().allowCrossCompany(true);
this.query().addCompanyRange(“dat”);
this.query().addCompanyRange(“ceu”);

}

Advertisements

2 Responses to “Cross company reports [AllowCrossCompany] in Dynamics AX , X++”

  1. Gor Says:

    Hi.
    Thank you for this post. It was very helpfull.
    I have tried to implement a CrossCompany-AIF-Service for BizTalk with this tutorial. Unfortunately I get an error If there are more then 1 company.
    Do you know how to solve this problem?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: