Источник:
https://dynamicsaxinsight.wordpress....mation-in-xpp/
==============
Purpose:
The purpose of this blog post is to demonstrate how to create contact information in X++
Product:
Dynamics AX 2012
Description:
The code create contact information with purpose “Collection” on the customer record.
Code:
static void MAKCustContactCreate(Args _args) { #define.LocationRoleName('Collection') CustTable custTable; DirPartyTable dirPartyTable; LogisticsElectronicAddress logisticsElectronicAddress; LogisticsLocationRole locationRole; Map locationRoleMap; container locationRoleCon; ; custTable = CustTable::find('C000115'); dirPartyTable = DirPartyTable::findRec(custTable.Party); if (!dirPartyTable.existElectronicAddrbyRole(#LocationRoleName)) { locationRoleMap = new Map(Types::Int64, Types::String); locationRole = LogisticsLocationRole::findByName(#LocationRoleName); if (locationRole) { locationRoleMap.insert(locationRole.RecId, locationRole.description()); locationRoleCon = map2Con(locationRoleMap); ttsBegin; logisticsElectronicAddress.Type = LogisticsElectronicAddressMethodType::Email; logisticsElectronicAddress.Locator = 'testUserAccount2@domain.com'; logisticsElectronicAddress.Location = DirPartyLocation::findOrCreate(CustTable.Party, 0).Location; logisticsElectronicAddress = LogisticsElectronicAddress::findOrCreate(logisticsElectronicAddress); logisticsElectronicAddress = LogisticsElectronicAddress::findRecId(logisticsElectronicAddress.RecId, true); logisticsElectronicAddress.Description = "Email from X++"; logisticsElectronicAddress.IsPrimary = NoYes::No; logisticsElectronicAddress.update(); LogisticsEntityLocationRoleMap::createEntityLocationRoles(tableNum(LogisticsElectronicAddressRole), logisticsElectronicAddress.RecId, conPeek(locationRoleCon, 1), true); ttsCommit; info(strFmt("Created/updated email address %1 for customer %2.", logisticsElectronicAddress.Locator, custTable.AccountNum)); } } }
Источник:
https://dynamicsaxinsight.wordpress....mation-in-xpp/