Like in thread tittle. How or by what can I get LocationAddress info having inventsiteid ?? There are so many tables and views im confused. I need to pick site address for current siteid.
Create this job and replace the inventSiteId
with your site.
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);
}
Tried both methods but info didnt give me anything here. BTW I need to get a int64 adresslocation since I need to put it into a field of PurchCreateOrder.
Did you replace the text
MySite
with your site? This code works...you need to provide more information when you just say "It doesn't work". Does yourinventSite
variable above contain a value?SiteLocation.Location
is the location recid. The data is all there. Debug your code.By bad. Didnt explained it well. It works but.. in my sitelocation are only 2 locations pasted. So this code works for 2 of 20 addresses. I should get it somewhere from DIrPartyTables I think. They are somehow connected to siteid but I cant find where.
The value I need must be int64 to put it into a form field
Edit your question or ask a new question, this answer solves exactly what you're asking. Your question is just a title of a post, plus you repeat the same question in the body. Please see Asking a good question. Try to understand from the perspective of someone answering this. I provide two correct solutions to the problem, then you basically say "it doesn't work", then you ask a new question in the comment. And this has happened on multiple questions now. It makes me question the time spent answering.