CROSSCOMPANY AND CHANGECOMPANY IN D365 AX 7 DYNAMICS CODE
Cross-Company Data Modification Using X++
X++ example uses the forUpdate keyword on the while select crossCompany statement. Only one table buffer variable is declared. This example also uses the update method on the table buffer.In order to use crosscompany or changecompany in d365 use the following code .
static void JobCCForUpdMethod( Args _args )
{
Table21 tab21;
;
ttsBegin;
while select
forUpdate crossCompany
countOfReviews
from
tab21
{
changeCompany( tab21 .dataAreaId )
{
tab21 .countOfReviews = tab21 .countOfReviews + 2;
tab21 .update();
}
}
ttsCommit;
}
the above code is taken from here