Insert Item from Company A into Company B

tompynationtompynation Member Posts: 398
Hi,

I would like to achieve the following:

When there is an item Created in Company A, this item should also get Created automatically in Company B
Same when updating in Company A, the item in Company B should also be Updated...

How can i achieve this ?

Comments

  • matttraxmatttrax Member Posts: 2,309
    Item.CHANGECOMPANY(Other Company);
    //Do you thing with the item
  • tompynationtompynation Member Posts: 398
    How you mean ChangeCompany and then do your thing...

    When i am in the OnModify function of the Item table (Comp. A), how will i know if the item exists in Comp. B ?
    And how will i update it then, or if it doesnt exist insert in Comp. B
  • matttraxmatttrax Member Posts: 2,309
    Sorry, thought it was clear from the code.

    Say you are in Company A. Item is a record from the Item table.
    In OnInsert or OnModify you would need to do:

    Item.CHANGECOMPANY(Company B);
    IF NOT Item.GET("No.") THEN
    Item.INSERT;

    The CHANGECOMPANY function literally points that record variable to another company, so even though you may be operating in Company A, that record variable will only see records in the company you've changed to.

    Is that more clear?
  • jversusjjversusj Member Posts: 489
    matttrax wrote:
    Sorry, thought it was clear from the code.

    Say you are in Company A. Item is a record from the Item table.
    In OnInsert or OnModify you would need to do:

    Item.CHANGECOMPANY(Company B);
    IF NOT Item.GET("No.") THEN
    Item.INSERT;

    The CHANGECOMPANY function literally points that record variable to another company, so even though you may be operating in Company A, that record variable will only see records in the company you've changed to.

    Is that more clear?

    ..but remember to watch any field that validates, as the validation logic will not be impacted by the change company logic (in some cases you can get away with it (like if the validate is just a lookup to a table that contains the same data in all companies). i'd search the forum for CHANGECOMPANY and learn from that.
    kind of fell into this...
  • garakgarak Member Posts: 3,263
    Follow the link.

    viewtopic.php?f=23&t=32588

    In this post is also the link to Alex's BLOG

    Regards
    Do you make it right, it works too!
Sign In or Register to comment.