Cross company Keyword:
CrossCompany is the Keyword to get the data from other companies in AX.
static void CrossCompanyExample(Args _args)
{
CustTable _custtable;
;
while select crosscompany * from _custtable
{
info(strfmt("%1 %2",_custtable.AccountNum,_custtable.dataAreaId));
}
}
It will list the account numbers and the company associated for all the companies in Ax.
Consider listing customers from selected companies.There are two ways to do it.
1) Using a Container :
static void CrossCompanyExample(Args _args)
{
CustTable _custtable;
Container list = ["hksa","idss"];
;
while select crosscompany:list * from _custtable
{
info(strfmt("%1 %2",_custtable.AccountNum,_custtable.dataAreaId));
}
}
2) Using a Query :
static void UseOfCrossCompanywithQuery(Args _args)
{
Query query = new Query();
QueryBuildDataSource qbds = query.addDataSource(tableNum(CustTable));
QueryRun queryRun;
CustTable custTable;
;
query.allowCrossCompany(true);
query.addCompanyRange("hksa");
query.addCompanyRange("idss");
queryRun = new QueryRun(query);
while (queryRun.next())
{
custTable = queryRun.get(tableNum(CustTable));
info(strfmt("%1 %2",custTable.AccountNum,custTable.dataAreaId));
}
}
Happy Daxing :)
CrossCompany is the Keyword to get the data from other companies in AX.
static void CrossCompanyExample(Args _args)
{
CustTable _custtable;
;
while select crosscompany * from _custtable
{
info(strfmt("%1 %2",_custtable.AccountNum,_custtable.dataAreaId));
}
}
It will list the account numbers and the company associated for all the companies in Ax.
Consider listing customers from selected companies.There are two ways to do it.
1) Using a Container :
static void CrossCompanyExample(Args _args)
{
CustTable _custtable;
Container list = ["hksa","idss"];
;
while select crosscompany:list * from _custtable
{
info(strfmt("%1 %2",_custtable.AccountNum,_custtable.dataAreaId));
}
}
2) Using a Query :
static void UseOfCrossCompanywithQuery(Args _args)
{
Query query = new Query();
QueryBuildDataSource qbds = query.addDataSource(tableNum(CustTable));
QueryRun queryRun;
CustTable custTable;
;
query.allowCrossCompany(true);
query.addCompanyRange("hksa");
query.addCompanyRange("idss");
queryRun = new QueryRun(query);
while (queryRun.next())
{
custTable = queryRun.get(tableNum(CustTable));
info(strfmt("%1 %2",custTable.AccountNum,custTable.dataAreaId));
}
}
Happy Daxing :)
No comments:
Post a Comment