Saturday, 4 July 2020

Get InventSite Address from InventSite ID in AX 2012

Primary address stored for inventSite 




The following job takes inventsiteID and returns the delivery address specified in the invent site. Hope it will help someone.

static void addressTest(Args _args)
{
    InventSite site = InventSite::find("S02");
    LogisticsPostalAddress address = LogisticsLocationEntity::findPostalAddress(site, LogisticsLocationRoleType::None);
    info(address.Address);
}


Phone Details

private Phone getSitePhone(InventSiteId _inventSiteID)
{
    InventSite site = InventSite::find(_inventsiteID);
    LogisticsElectronicAddress  logisticsElectronicAddress;
    LogisticsLocationEntity locationEntity = LogisticsLocationEntity::findLocation(site, LogisticsLocationRoleType::Delivery, DirUtility::getCurrentDateTime(),true);
    RecId parentRecID= locationEntity.parmLocationRecId();
   LogisticsLocation           logisticsLocation;
   if (parentRecID )
   {
      select logisticsLocation
           where  logisticsLocation.ParentLocation == parentRecID
           join logisticsElectronicAddress
               where logisticsElectronicAddress.Type     == LogisticsElectronicAddressMethodType::Phone &&
                   logisticsElectronicAddress.location == logisticsLocation.RecId;
   }
   return logisticsElectronicAddress.Locator;
}

No comments:

Post a Comment

POSTMAN D365

  Postman is useful to test the behavior of different OData class from/to D365FO. In this post we will see the steps to setup Postman with D...