CREATE PHONE NUMBER OF A CUSTOMER IN DYNAMICS AX D365
Below code is used to create a Phone number or a email of a customer through code.
static void
CreatePhoneExample(Args _args)
{
CustTable custTable =
CustTable::find('SLPL-000006');
LogisticsElectronicAddress logisticsElectronicAddress;
container defaultRole =
map2Con(LogisticsLocationEntity::getDefaultLocationRoleFromEntity(tableNum(DirPartyTable)));
setPrefix(strFmt("Creating/Updating
number for customer %1", custTable.AccountNum));
ttsBegin;
logisticsElectronicAddress.Type =
LogisticsElectronicAddressMethodType::Email;
logisticsElectronicAddress.Locator =
"123@123";
logisticsElectronicAddress.Location =
DirPartyLocation::findOrCreate(custTable.Party, 0).Location;
logisticsElectronicAddress =
LogisticsElectronicAddress::findOrCreate(logisticsElectronicAddress);
logisticsElectronicAddress =
LogisticsElectronicAddress::findRecId(logisticsElectronicAddress.RecId, true);
logisticsElectronicAddress.Description =
"New Email Address";
logisticsElectronicAddress.IsPrimary =
NoYes::Yes;
logisticsElectronicAddress.update();
LogisticsEntityLocationRoleMap::createEntityLocationRoles(tableNum(LogisticsElectronicAddressRole),
logisticsElectronicAddress.RecId, conPeek(defaultRole, 1), true);
info(strFmt("Created/updated phone
number [%1] for customer %2.", logisticsElectronicAddress.Locator,
custTable.AccountNum));
ttsCommit;
}
Thanks,
Vikas Mehta
No comments:
Post a Comment