Join Address & Custtable using x++ :
JOIN
ADDRESS and CUSTTABLE
static
void FindPrimaryAddress(Args _args)
{
CustTable custTable;
Address primaryAddress;
;
custTable = CustTable::find("ABCD", false);
//first way
primaryAddress = dirPartyAddress::findPrimaryAddress(custTable.PartyId);
info(strFmt("Street: %1", primaryAddress.Street));
}
{
CustTable custTable;
Address primaryAddress;
;
custTable = CustTable::find("ABCD", false);
//first way
primaryAddress = dirPartyAddress::findPrimaryAddress(custTable.PartyId);
info(strFmt("Street: %1", primaryAddress.Street));
}
tatic
void FindPrimaryAddress(Args _args)
{
utcDateTime dateTimeNow = DateTimeUtil::utcNow();
CustTable custTable;
DirPartyAddressRelationship dpar;
DirPartyAddressRelationshipMapping dparm;
Address address;
;
select firstfast firstonly custTable;
select firstfast firstonly dpar
where dpar.PartyId == custTable.PartyId
&& dpar.Status == DirPartyAddressRelationshipStatus::Active
&& dpar.ValidFromDateTime <= dateTimeNow
&& dpar.ValidToDateTime >= dateTimeNow
&& dpar.IsPrimary == NoYes::Yes;
select firstfast firstonly dparm
where dparm.PartyAddressRelationshipRecId == dpar.RecId;
select firstfast firstonly address
where address.RecId == dparm.AddressRecId;
info(strFmt('Primary address for %1 is %2', custTable.Name, address.Address));
}
{
utcDateTime dateTimeNow = DateTimeUtil::utcNow();
CustTable custTable;
DirPartyAddressRelationship dpar;
DirPartyAddressRelationshipMapping dparm;
Address address;
;
select firstfast firstonly custTable;
select firstfast firstonly dpar
where dpar.PartyId == custTable.PartyId
&& dpar.Status == DirPartyAddressRelationshipStatus::Active
&& dpar.ValidFromDateTime <= dateTimeNow
&& dpar.ValidToDateTime >= dateTimeNow
&& dpar.IsPrimary == NoYes::Yes;
select firstfast firstonly dparm
where dparm.PartyAddressRelationshipRecId == dpar.RecId;
select firstfast firstonly address
where address.RecId == dparm.AddressRecId;
info(strFmt('Primary address for %1 is %2', custTable.Name, address.Address));
}
0 comments:
Post a Comment