Execute a job on data in several companies
There is a verry simple trick to loop through some companies and execute some code in them.
Just write:
DataArea dataArea; ; while select dataArea where !dataArea.isVirtual { changecompany(dataArea.id) { // Do Something... } }
Note! Make sure that you clear the table variable after each companychange (common = null;).
Tags: Company, Dynamics AX, Programming, Tips & Tricks, X++
This entry was posted on Thursday, April 29th, 2010 at 06:00 and is filed under Dynamics AX. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.


April 29th, 2010 at 15:45
Could you please expand on your comment “Note! Make sure that you clear the table variable after each companychange (common = null;).”
April 30th, 2010 at 12:19
Execute a job on data in several companies – part2 | Doens.be says:[...] one of my previous posts I explained that you can switch company with the keyword changecompany. I also made a remark that you should set the value of your table-value to null after each [...]