Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Contact information on Customer Accounts

Posted on by 572

Hi Experts,

I need to run a job to stop the customer account for all transactions if there is no Email details specified in the contact information (at least one email account no need to look for primary or not). I was trying with below code but it doesn't work. 

static void BlockCustomerAccount_Contact(Args _args)
{
CustTable custtable;
LogisticsElectronicAddress logisticselectronicaddress;
DirPartyLocation dirPartyLocation;
LogisticsLocation logisticsLocation;

ttsbegin;
while select forupdate CustTable
join dirPartyLocation where custtable.Party == dirPartyLocation.Party
join LogisticsLocation where LogisticsLocation.RecId == DirPartyLocation.Location
join logisticsElectronicAddress where logisticsElectronicAddress.Location == logisticsLocation.RecId
&& logisticsElectronicAddress.Type != LogisticsElectronicAddressMethodType::Email
&& custtable.Blocked != CustVendorBlocked::All


{

custtable.Blocked = CustVendorBlocked::All;
custtable.doUpdate();
Info(strFmt("%1 - Blocked ", custtable.AccountNum));
}

ttscommit;

}

*This post is locked for comments

  • Suggested answer
    guk1964 Profile Picture
    guk1964 10,877 on at
    RE: Contact information on Customer Accounts

    Why not push it all to Excel and filter there- then the users can review correct, complete as needed and then import back.

    P.S. as Kurt mentioned in one of his blogs re D365 due to a particular index seek in a query, missing contact data can give big performance issues. So another reasons for users to clean up their data. 

  • Suggested answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Contact information on Customer Accounts

    You cannot find records that do not have matching records with inner join, you need to use notexists join, something like this:

    while select custTable
            notexists join dirPartyContactInfoView
                where dirPartyContactInfoView.Party == custTable.Party
                   && dirPartyContactInfoView.Type  == LogisticsElectronicAddressMethodType::Email
        {
            
        }


  • D365  beginner Profile Picture
    D365 beginner 572 on at
    RE: Contact information on Customer Accounts

    Hi,

    Can anyone help me on the above code please.

  • D365  beginner Profile Picture
    D365 beginner 572 on at
    RE: Contact information on Customer Accounts

    Hi Ludwig,

    Thanks, Could you please correct the above code to run the job to stop the existing customers. So I can use the same for vendors also.

  • Suggested answer
    Ludwig Reinhard Profile Picture
    Ludwig Reinhard Microsoft Employee on at
    RE: Contact information on Customer Accounts

    Right. Or, you ask your users to fill the email manually afterwards :-)

    They might not like it but this is how they learn how important that information is and next time they have to fill it anyway if you make it a mandatory field ;-)

    Best regards,

    Ludwig

  • D365  beginner Profile Picture
    D365 beginner 572 on at
    RE: Contact information on Customer Accounts

    Hi Ludwig,

    Thanks for the reply, Yes we can do it for new customer accounts but still I need to stop the existing customers from transactions.

  • Suggested answer
    Ludwig Reinhard Profile Picture
    Ludwig Reinhard Microsoft Employee on at
    RE: Contact information on Customer Accounts

    Hi,

    Wouldn't it be better and easier making the email a mandatory field that needs to be entered when recording a new customer?

    Best regards,

    Ludwig

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans