Search code examples
axaptadynamics-ax-2012x++street-address

How to set InventLocation address by code?


I have to set the InventLocation Address by code. By code I know how to find the InventLocation address, but if it isn't there I want to create it.

My code is this :

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.
}

Is it possible to create it?


Solution

  • Your InventLocation.RecId will need to be referenced in InventLocationLogisticsLocation.Location, so obviously this table will need to have a record inserted. The next reference will be in InventLocationLogisticsLocationRole.LocationLogisticsLocation, again you will need a record. Finally, the reference in LogisticsPostalAddress.Location.

    So first insert into InventLocationLogisticsLocation, then into InventLocationLogisticsLocationRole, finally into LogisticsPostalAddress.

    Also make sure that you have a Role Type defined as None, otherwise you might be missing the record in LocationPostalAddress.