如何使用 inventsiteid x++ 获取地址
How to get Address using inventsiteid x++
喜欢线程标题。
我如何或通过什么可以获得具有 inventsiteid 的 LocationAddress 信息?
太多的表和视图让我感到困惑。
我需要为当前 siteid 选择站点地址。
这可能有点令人困惑。这篇文章非常适合您。
创建此职位并将 inventSiteId
替换为您的网站。
static void Job107(Args _args)
{
InventSiteId inventSiteId = 'MySite'; // PUT YOUR SITE HERE
InventSite inventSite = InventSite::find(inventSiteId);
InventSiteLogisticsLocation siteLocation;
InventSiteLogisticsLocationRole siteLocationRole;
LogisticsLocationRole locationRole;
LogisticsPostalAddress logisticsPostalAddress;
// Method 1 - List all addresses. Refine query as needed.
while select logisticsPostalAddress
join siteLocation
order by IsPrimary desc
where logisticsPostalAddress.Location == siteLocation.Location &&
siteLocation.Site == inventSite.RecId
join siteLocationRole
where siteLocationRole.SiteLogisticsLocation == siteLocation.RecId
join locationRole
where locationRole.RecId == siteLocationRole.LocationRole
{
info(strFmt("Role: %1; Address: %2", locationRole.Type, logisticsPostalAddress.Address));
}
// Method 2; 1-liner for single address, good for just getting primary. Change role type for different addresses
info(LogisticsPostalAddress::findByLocation(InventSite::getLocationFromRole(InventSite::find(inventSiteId).RecId, LogisticsLocationRoleType::Delivery)).Address);
}
喜欢线程标题。 我如何或通过什么可以获得具有 inventsiteid 的 LocationAddress 信息? 太多的表和视图让我感到困惑。 我需要为当前 siteid 选择站点地址。
这可能有点令人困惑。这篇文章非常适合您。
创建此职位并将 inventSiteId
替换为您的网站。
static void Job107(Args _args)
{
InventSiteId inventSiteId = 'MySite'; // PUT YOUR SITE HERE
InventSite inventSite = InventSite::find(inventSiteId);
InventSiteLogisticsLocation siteLocation;
InventSiteLogisticsLocationRole siteLocationRole;
LogisticsLocationRole locationRole;
LogisticsPostalAddress logisticsPostalAddress;
// Method 1 - List all addresses. Refine query as needed.
while select logisticsPostalAddress
join siteLocation
order by IsPrimary desc
where logisticsPostalAddress.Location == siteLocation.Location &&
siteLocation.Site == inventSite.RecId
join siteLocationRole
where siteLocationRole.SiteLogisticsLocation == siteLocation.RecId
join locationRole
where locationRole.RecId == siteLocationRole.LocationRole
{
info(strFmt("Role: %1; Address: %2", locationRole.Type, logisticsPostalAddress.Address));
}
// Method 2; 1-liner for single address, good for just getting primary. Change role type for different addresses
info(LogisticsPostalAddress::findByLocation(InventSite::getLocationFromRole(InventSite::find(inventSiteId).RecId, LogisticsLocationRoleType::Delivery)).Address);
}