A fast and simple Data Entity to use for integrating postal addresses.
Hello,
In this post I will highlight the DirPartyLocationPostalAddressV2Entity data entity. I found this entity when trying to determine which one to use to bring in postal addresses for vendors using a custom service. I was in interested in how to bring in a new postal address in the Addresses section of the VendTable form:
To test how to use the entity I used the following runnable class (job). Since custom services use X I was interested in first verifying the address came in correctly using a runnable class.
class EntityTestingXPP_Job
{
///
/// Runs the class with the specified arguments.
///
/// The specified arguments.
public static void main(Args _args)
{
DirPartyLocationPostalAddressV2Entity dirPartyLocationPostalAddressV2;
DirPartyTable partyTable;
PartyNumber partyNumber;
Name partyName;
VendTable vendTable = VendTable::find("1001", false);
partyTable = DirPartyTable::findRec(vendTable.Party, false);
partyNumber = partyTable.PartyNumber;
partyName = partyTable.Name;
if (partyNumber)
{
dirPartyLocationPostalAddressV2.clear();
dirPartyLocationPostalAddressV2.PartyNumber = partyNumber;
dirPartyLocationPostalAddressV2.City = "Fargo";
dirPartyLocationPostalAddressV2.CountryRegionId = "USA";
dirPartyLocationPostalAddressV2.CountryRegionISOCode = "US";
dirPartyLocationPostalAddressV2.County = "CASS";
dirPartyLocationPostalAddressV2.Description = "Acme Office Supplies";
dirPartyLocationPostalAddressV2.IsLocationOwner = NoYes::Yes;
dirPartyLocationPostalAddressV2.Roles = "Alt Delivery"; // This is the address purpose
dirPartyLocationPostalAddressV2.State = "ND";
dirPartyLocationPostalAddressV2.Street = "123 Sheyenne St";
dirPartyLocationPostalAddressV2.ZipCode = "58103";
dirPartyLocationPostalAddressV2.insert();
if (dirPartyLocationPostalAddressV2.RecId)
{
Info("Address created for " vendTable.AccountNum " Street: " dirPartyLocationPostalAddressV2.Street);
}
}
}
}
A few notes regarding the use of the entity in the code sample:
First, the postal address is associated to the Party for the vendor. This is the reason why the name of the entity starts with "DirParty" and why you need to retrieve the party number for the vendor so you can set the PartyNumber field. Since the data entity is linked to the Party number it can be used for any role in the global address book like Customers, Contacts, and Workers. So you can use one entity for either customers or vendors.
Second, an advantage to using this entity is you don't have to worry about the schema of the underlying address related tables. There are several tables that make up the relationship for a customer or vendor postal address. You only need to get the Party number and you are ready to go!
Lastly, if you need to delete the postal address with this entity you can use the delete method.
I hope this post can help you out in your postal address integration strategies!

Like
Report
*This post is locked for comments