In this topic, we will learn how to update the customer / vendor Email Address or Phone number
static void MK_CustomeremailUpdate(Args _args)
{
DirPartyTable dirparty;
DirPartyLocation dirPartyLocation;
LogisticsElectronicAddress elecAddress;
LogisticsElectronicAddressRole elecAddressRole;
LogisticsLocationRole locRole;
CustTable cust = CustTable::find('CXXX'');///Replace with vendTable for Vendors
// Update all the customers use the while loop or you can just use the above fine method to get the customer.
while select cust
where cust.AccountNum != " "
{
select forUpdate firstOnly elecAddress
where elecAddress.Location == DirPartyLocation::findOrCreate(cust.Party, 0).Location
&& elecAddress.Type == LogisticsElectronicAddressMethodType::Email; // Replace with Phone to update phone number
if (elecAddress.RecId)
{
info(strFmt("%1 , %2 - email - %3", cust.AccountNum, cust.name(),elecAddress.Locator));
ttsBegin;
elecAddress.Type = LogisticsElectronicAddressMethodType::Email; // for phone type should be phone
elecAddress.Locator = 'xxx.aaa@xxx.com'; // for phone number give the new Phone number
elecAddress.update();
ttsCommit;
info(strFmt("%1 , %2 - email - %3", cust.AccountNum, cust.name(),elecAddress.Locator));
}
}
}
static void MK_CustomeremailUpdate(Args _args)
{
DirPartyTable dirparty;
DirPartyLocation dirPartyLocation;
LogisticsElectronicAddress elecAddress;
LogisticsElectronicAddressRole elecAddressRole;
LogisticsLocationRole locRole;
CustTable cust = CustTable::find('CXXX'');///Replace with vendTable for Vendors
// Update all the customers use the while loop or you can just use the above fine method to get the customer.
while select cust
where cust.AccountNum != " "
{
select forUpdate firstOnly elecAddress
where elecAddress.Location == DirPartyLocation::findOrCreate(cust.Party, 0).Location
&& elecAddress.Type == LogisticsElectronicAddressMethodType::Email; // Replace with Phone to update phone number
if (elecAddress.RecId)
{
info(strFmt("%1 , %2 - email - %3", cust.AccountNum, cust.name(),elecAddress.Locator));
ttsBegin;
elecAddress.Type = LogisticsElectronicAddressMethodType::Email; // for phone type should be phone
elecAddress.Locator = 'xxx.aaa@xxx.com'; // for phone number give the new Phone number
elecAddress.update();
ttsCommit;
info(strFmt("%1 , %2 - email - %3", cust.AccountNum, cust.name(),elecAddress.Locator));
}
}
}
No comments:
Post a Comment