Tuesday, March 23, 2021

get warehouse address In D365FO

 If you want to get address of from warehouse:


InventLocation::find(InventLocationId).logisticsPostalAddress().Address;

InventLocation::find(InventLocationId).Address();

--------------------------------------------or--------------------------------------------------------

Based on role type:

Get delivery type primary address of warehouse:


public static RefRecId getDeliveryAddressRecid(InventLocationId _inventLocationId) { InventLocation inventlocation = InventLocation::find(_inventLocationId); InventLocationLogisticsLocation inventLocationLogisticsLocation; InventLocationLogisticsLocationRole inventLocationLogisticsLocationRole; LogisticsLocationRole logisticsLocationRole; LogisticsPostalAddress postalAddress; select firstonly location from inventLocationLogisticsLocation where inventLocationLogisticsLocation.InventLocation == inventLocation.RecId && inventLocationLogisticsLocation.IsPrimary == true exists join inventLocationLogisticsLocationRole where inventLocationLogisticsLocationRole.LocationLogisticsLocation == inventLocationLogisticsLocation.RecId exists join logisticsLocationRole where inventLocationLogisticsLocationRole.LocationRole == logisticsLocationRole.RecId && logisticsLocationRole.Type == LogisticsLocationRoleType::Delivery; if (inventLocationLogisticsLocation.Location) { TransDateTime now = DateTimeUtil::getSystemDateTime(); select firstonly validtimestate(now) RecId from postalAddress where postalAddress.Location == inventLocationLogisticsLocation.Location; } return postalAddress.RecId ? postalAddress.RecId : nullValueFromType(Types::Int64); }

--------------------------------------------or--------------------------------------------------------

public static void getDeliveryAddress(RefRecId _inventLocationRecId) {

    InventLocationLogisticsLocation        inventLocationLogisticsLocation;

    Select firstOnly inventLocationLogisticsLocation     where inventLocationLogisticsLocation.InventLocation == _inventLocationRecId     && inventLocationLogisticsLocation.IsPrimary == NoYes::Yes;

}


Keep Daxing!!

No comments:

Post a Comment