Sunday, 24 September 2017

Update Customer / Vendor Email address or phone number AX 2012 X++

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));
        }
       
    }
}

No comments:

Import and Export file from BLOB storage Account(Azure) in D365 F&O using X++

  Import and Export file from BLOB storage Account in D365 F&O using X++ Import: /// <summary> /// MKInventQualityOrderLineService...