web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

How to change company by the X++ code in AX 2009 ??

Abdel Fatah Ahmed Profile Picture Abdel Fatah Ahmed
sometimes you need to change company by code to get some information from company to put it in another one like update the price for company X by the price you get from company Y and this example will explain :
void clicked()
{
inventtable _inventtable;
InventTableModule invtm;
InventTableModule invtmhaq;
int counter=0;
///////////////////////////////////////////////////////////////////////////////
////////////////////////////Code Begining//////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
ttsbegin;
        try
        {
              changecompany('sdx')
              {
                while select invtm
                {
                    if(invtm)
                    {
                        changecompany('haq')
                        {
                            while select forupdate invtmhaq where invtmhaq.ItemId == invtm.ItemId
                            {
                                if(invtmhaq)
                                {
                                      invtmhaq.Price= invtm.Price;
                                      invtmhaq.update();
                                      counter++;
                                 }
                            }
                        }
                    }
                }
              }
       }
            catch
                {
                Error(strfmt("Can not apple to insert "));
                }
 ttscommit;
 info(strfmt("Number Of rows Inserted : %1",counter));

}

Comments

*This post is locked for comments