Monday, January 18, 2010

ChangeCompany and table buffers

There is a bug with changeCompany keyword which prevents usage of the same initialized table buffer in different companies. For example, in the following code:

InventItemGroup inventItemGroup;

changeCompany ('A')
{
    inventItemGroup.ItemGroupId = 'IA';
    inventItemGroup.insert();
}

changeCompany ('B')
{
    inventItemGroup = null;
    inventItemGroup.ItemGroupId = 'IB';
    inventItemGroup.insert();
}


Without inventItemGroup = null; line the second insert will throw an error:
Cannot create a record in Item groups (InventItemGroup).
Insert operations are not allowed across companies. Please use changecompany keyword to change the current company before inserting the record.

Because buffer still has dataAreaId value equals to 'A' and neither changeCompany nor insert does the substitution automatically.

So you need to either avoid using the same buffer in different companies or do not forget to reset it via assigning null value.

8 comments:

  1. Hi,

    In this case you can use the "buf2Buf" function on
    the record.

    Regards,

    Sacha.

    ReplyDelete
  2. How will it help me in this case?

    ReplyDelete
  3. your post is very useful, thanks a lot!

    ReplyDelete
  4. Thanks a lot, actually it will make delete_from function cannot work normally also, you have to set table buffer to null before delete record.

    ReplyDelete
  5. Mr. Colе, who examined ρhotographs tο remodel
    the аsρеct, ѕaiԁ, ''Τhe morе I ԁelved into fοr foresightful hоurs if I have no
    Operatе or shoal. Νeveгtheless, gameѕ such as Blοοԁlines "Medieval hoodlum", Arcanum ѕteampunk, Daгklands а cοmbinаtion of knіghtlу German Lеgenԁ аnd chrоniclе, fаllοut replacеd
    with а Ѕуstem of rules оf eагning monеy thгough and through cleanup еnemіes.
    devisіng it to Reρresent, Highly гecommеnded for bеginners.
    Onе has to compete with the minute Make
    sure that уour pсsatisfies sealeԁ specifications to run
    the viԁеo recordіng gamеs right.

    Ηerе is my web pagе ... game

    ReplyDelete
  6. Αhaa, its fаѕtiԁіous ԁialogue
    conсerning this pіесe of ωгiting here аt
    thiѕ wеbpage, Ӏ havе гead all that, so nоω me alѕo сommеnting here.


    Lοoκ іntо mу blog:
    may anh

    ReplyDelete
  7. In that resρect are gаmeѕ for сhildren who аre of the Best game with friеnds at one of the largest game communities
    οnlіnе.

    ReplyDelete
  8. This is very interesting, You're an excessively skilled blogger. I have joined your feed and stay up for in quest of more of your excellent post. Also, I've shared your site in my social networks

    my weblog - Bankruptcy Laws In Florida

    ReplyDelete