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;).

  1. Eric says:

    Could you please expand on your comment “Note! Make sure that you clear the table variable after each companychange (common = null;).”

  2. […] 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 […]

Comments are closed.