如何按代码设置InventLocation地址?

时间:2016-02-04 17:34:12

标签: axapta dynamics-ax-2012 x++ street-address

我必须按代码设置InventLocation 地址。 通过代码,我知道如何找到InventLocation地址,但如果不存在,我想创建它。

我的代码是:

InventLocation   invLocationTable;
LogisticsPostalAddress logisticsPostalAddress;

invLocationTable  = InventLocation::find(MYinvLocationId);
logisticsPostalAddress = LogisticsLocationEntity::findPostalAddress(invLocationTable, LogisticsLocationRoleType::None);

if (!logisticsPostalAddress )
{
 // Here I want to create/set the InventLocation adress, but I don't know how to do it.
}

是否可以创建它?

1 个答案:

答案 0 :(得分:0)

您的InventLocation.RecId需要在InventLocationLogisticsLocation.Location中引用,因此显然此表需要插入一条记录。下一个参考将在InventLocationLogisticsLocationRole.LocationLogisticsLocation中,您将需要一个记录。最后,在LogisticsPostalAddress.Location中引用。

首先插入InventLocationLogisticsLocation,然后插入InventLocationLogisticsLocationRole,最后插入LogisticsPostalAddress。

还要确保您将角色类型定义为None,否则您可能会错过LocationPostalAddress中的记录。