Below method will check if a customer contains a specific Location Role or not and find the Logistics Location Id for that specific location role:
This is where you can check the location role for a customer:
public LogisticsLocationId getLogisticsLocationId(CustAccount _custAccount)
{
DirPartyAddressLocationRoleNames locationRoleNames;
DirPartyPostalAddressView addressView;
LogisticsLocation logisticsLocation;
CustTable custTable = CustTable::find(_custAccount);
select firstonly PartyLocation from addressView
where addressView.Party == custTable.Party;
locationRoleNames = addressView.locationRoles();
str billTo = 'Bill to'; // Here you should write the name of your location role which needs to be find out.
if (strScan(locationRoleNames, billTo, 1, strLen(locationRoleNames)))
{
DirPartyLocation dirPartyLocation;
select firstonly LocationId from logisticsLocation
join Location from dirPartyLocation
where logisticsLocation.RecId == dirPartyLocation.Location
&& dirPartyLocation.Party == custTable.Party;
}
return logisticsLocation.LocationId;
}
No comments:
Post a Comment