AX / D365FO – Change default company in X++

If you want to change the company during the code (i.e. in a Runnable class or a job) you can use changeCompany(‘xxx’) command like shown in this example :

public static void main(Args _args)
    SalesLine   salesLine;

    changeCompany('USMF') //Default company is now 'USMF'.
        while select salesLine 
                where salesLine.SalesId == 'XXX-002011'
           // do something....

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s