In dynamics ax 2012 and 2009 to set the company while executed the code we used to select the company from the bottom screen option.
But in new Dynamics 365 for finance and operations for code execution we have to set it at the project property by default it is 'DAT'.
To do this go to project and right click and click on properties.
A new window will be opened. Set the property as shown in image.
Other way to do this is to use code to change the property. By default the company is 'DAT'. So to execute a code where we want to select a particular company and select a vendor, use below code.
We will be using change company function which has been available for all the versions of ax.
For this create a runnable class.
public static void main(Args _args)
{
VendTable vendTable;
ttsbegin;
info("Company info");
info(vendTableupdate.DataAreaId);
changecompany('USMF')
{
select firstonly vendTableupdate where vendTableupdate.AccountNum == '1002';
info("Company info");
info(vendTableupdate.DataAreaId);
}
ttscommit;
}
Above code is the example of changecompany() function.
Happy daxing!!!
But in new Dynamics 365 for finance and operations for code execution we have to set it at the project property by default it is 'DAT'.
To do this go to project and right click and click on properties.
A new window will be opened. Set the property as shown in image.
Other way to do this is to use code to change the property. By default the company is 'DAT'. So to execute a code where we want to select a particular company and select a vendor, use below code.
We will be using change company function which has been available for all the versions of ax.
For this create a runnable class.
public static void main(Args _args)
{
VendTable vendTable;
ttsbegin;
info("Company info");
info(vendTableupdate.DataAreaId);
changecompany('USMF')
{
select firstonly vendTableupdate where vendTableupdate.AccountNum == '1002';
info("Company info");
info(vendTableupdate.DataAreaId);
}
ttscommit;
}
Above code is the example of changecompany() function.
Happy daxing!!!
Comments
Post a Comment