Description:-
In this Example we will see how to Change Company Dynamically in Ax while Codding in form or any other else in ax. ChangeCompany is nothing but if we want to see data from other company Data then we can directly change in Coding through in Ax. Let’s see a demo how to change when we want data from other company. Here company is nothing but a legal entity where can store our configuration and data.
Create table and add data from different company so we can check through code behind in ax table.
Step 1: Create Table Name it “CrossCompanyDataCheck”. And Insert Filed in Table.
- Expand AOT Node.
- Open Data Dictionary Node.
- Select Tables and right Click Select New Table.
- Name it “CrossCompanyDataCheck”.
- Now open table in Insert Some Data in CrossCompanyDataCheck table.
Create Job from AOT
- In the AOT, click Job.
- Right-click the Job node, and then select New Job.
Code:-
static void ChangeCompany(Args _args) { CompanyName nameOfCompany; dev_multilinejournaltrans contractCompany; // trying to check companycode field from this table CompanyInfo company; ; // contractCompany = axpContractTable::find(warehouseTable.ContractId); //if (contractCompany.CompanyCode) while select contractCompany { if(contractCompany.dataAreaId == 'susb') { changecompany(contractCompany.LegalEntity) { nameOfCompany = curext(); info(strFmt("Name : %1",nameOfCompany)); } } if (contractCompany.dataAreaId == 'ceed') { changecompany(contractCompany.LegalEntity) { nameOfCompany =curext(); info(strFmt("Name : %1",nameOfCompany)); } } if (contractCompany.dataAreaId == 'ceu') { changecompany(contractCompany.LegalEntity) { nameOfCompany =curext(); info(strFmt("Name : %1",nameOfCompany)); } } //info(strFmt("Comapny-Name : %1",nameOfCompany)); } }
Thanks for comments.....