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”);
}
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”);
}