I find the way Ax 2009 deals with the global address book quite complicated but help is on hand in the form of a white paper (AX 2012 version). However, I started by looking at the CustTable.deliveryAddress() and the Address.insert(..., ...) methods.
Below is an example of adding and editing the secondary invoice address:
static void Job1(Args _args)
{
CustTable custTable;
DirPartyTable dirPartyTable;
Address invoiceAddress;
;
custTable = CustTable::find("1");
dirPartyTable = DirPartyTable::find( custTable.PartyId );
// Find private address for invoicing
invoiceAddress = Address::find(dirPartyTable.TableId, dirPartyTable.RecId, AddressType::Invoice, true);
if (!invoiceAddress)
{
invoiceAddress.AddrRecId = dirPartyTable.RecId;
invoiceAddress.AddrTableId = dirPartyTable.TableId;
invoiceAddress.type = AddressType::Invoice;
invoiceAddress.IsPrimary = NoYes::No;
}
invoiceAddress.Name = "Invoice Addressee";
invoiceAddress.CountryRegionId = "ES";
invoiceAddress.Street = "Calle de los perdidos";
invoiceAddress.ZipCode = "50000";
invoiceAddress.City = "Zaragoza";
invoiceAddress.County = "ZARAGOZA";
invoiceAddress.State = "AR";
invoiceAddress.AddressMap::formatAddress();
if (invoiceAddress.RecId == 0)
{
invoiceAddress.insert(true, false);
}
else
{
invoiceAddress.update(true, false);
}
}
No hay comentarios:
Publicar un comentario