Monday, December 11, 2023

Get warehouse contact information based on purpose in D365 F&O

 

 public container getWarehouseReleaseEmailAddress(InventLocationId _inventLocationId)

    {

     

        InventLocationLogisticsLocation inventLocationLogisticsLocation;

        InventSiteLogisticsLocation     inventSiteLogisticsLocation;

        LogisticsElectronicAddress      logisticsElectronicAddress;

        LogisticsLocation               logisticsLocation;

        InventLocation                  inventLocation;

        LogisticsElectronicAddressRole  elecAddressRole;

        LogisticsLocationRole           locRole;

        container                       conEmail;


        conEMail = conNull();



        // Get warehouse from communication details

        while select inventlocation

        join inventLocationLogisticsLocation

            where inventLocationLogisticsLocation.InventLocation == inventlocation.RecId

            && inventlocation.InventLocationId == _inventLocationId

        join logisticsLocation

            where logisticsLocation.ParentLocation == inventLocationLogisticsLocation.Location

        join firstOnly logisticsElectronicAddress

            where logisticsElectronicAddress.Location == logisticsLocation.RecId

            && logisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Email

            join elecAddressRole

                where elecAddressRole.ElectronicAddress == logisticsElectronicAddress.RecId

            join locRole

                where locRole.RecId == elecAddressRole.LocationRole

                && locRole.Type == LogisticsLocationRoleType::None

                && locRole.Name == 'Warehouse Release'

        {

            if (!conFind(conEMail, logisticsElectronicAddress.Locator))

            {

                conEMail += logisticsElectronicAddress.Locator;

            }

           

        }

 


        return conEMail;

      

No comments:

Post a Comment