最新消息:ww12345678 的部落格重装上线,希望大家继续支持。

ChangeCompany and table buffers

网络文摘 William 1910浏览 0评论
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.
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址