Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

Query is Sending wrong data can you please help !!

(0) ShareShare
ReportReport
Posted on by

while select AccountNum, TransDate from vendTrans group by vendTrans.AccountNum where vendTrans.TransDate==fromdate
{
Info(vendTrans.AccountNum);
if( localAccount != vendTrans.AccountNum)
{
select AccountNum ,party from vendTable where vendTable.AccountNum==vendTrans.AccountNum
join Name from partyTable where partyTable.RecId==vendTable.Party join
Locator from logisticsElectronicAddress where logisticsElectronicAddress.RecId==partyTable.PrimaryContactEmail;
str emails = logisticsElectronicAddress.Locator;

mailer.addTo(emails);
mailer.setSubject(strFmt(" Payment Details - %1 %2",vendTable.AccountNum,partyTable.Name));
body = "Hi Dear " + strFmt(" %1 <br/><br/> Vendor Account No. : %2 <br/> ",partyTable.Name,vendTable.AccountNum) ;


}
localAccount = vendTable.AccountNum;
}
mailer.setBody(body,true) ;
SysMailerFactory::getNonInteractiveMailer().sendNonInteractive(mailer.getMessage()) ;

this query outputs two accounts INMF01 And INMF05 , now data needs to be sent to their primary email address we have added lets suppose x1@gmail.com and x2@gmail.com(picking from locator in logistics electronic address) for both accounts respectively but this query is also sending INMF05 to x1@gmail.com also , only INMF01 to x1@gmail.com and INMF to X2@gmail.com needs to be sent

  • RE: Query is Sending wrong data can you please help !!

    thankyou it worked

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,842 Most Valuable Professional on at
    RE: Query is Sending wrong data can you please help !!

    I think you want something like this:

    while select AccountNum from vendTrans
    	group by vendTrans.AccountNum
    	where vendTrans.TransDate == fromDate
    {
    	info(vendTrans.AccountNum);
    
    	select AccountNum from vendTable
    		where vendTable.AccountNum == vendTrans.AccountNum
    			join Name from partyTable
    				where partyTable.RecId == vendTable.Party
    			join Locator from logisticsElectronicAddress
    				where logisticsElectronicAddress.RecId == partyTable.PrimaryContactEmail;
    				
    	str email = logisticsElectronicAddress.Locator;
    
    	SysMailerMessageBuilder mailer = new SysMailerMessageBuilder();
    
    	mailer.addTo(email);
    	mailer.setSubject(strFmt("Payment Details - %1 %2", vendTable.AccountNum, partyTable.Name));
    	body = strFmt("Hi Dear %1 

    Vendor Account No. : %2
    ", partyTable.Name, vendTable.AccountNum); mailer.setBody(body, true); SysMailerFactory::sendNonInteractive(mailer.getMessage()); }

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Query is Sending wrong data can you please help !!

    You have added the info log to account number. How many times that info is printing?

    Also in the while select try adding order by vendTrans.AccountNum and check.

    Thanks,

    Girish S.

  • RE: Query is Sending wrong data can you please help !!

    yes this is sending INMF01 to x1@gmail.com only that's correct but for INMF05 its sending mail to both x1@gmail.com and x2@gmail.com

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Query is Sending wrong data can you please help !!

    So you are saying that INMF01 has x1@gmail.com and INMF05 has x2@gmail.com. But your code sending INMF05 to both x1@gmail.com and x2@gmail.com.

    Is the above correct?

    Thanks,

    Girish S.

  • RE: Query is Sending wrong data can you please help !!

    not working sir

  • Suggested answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Query is Sending wrong data can you please help !!

    Seems your code SysMailFactory will need to be inside the while select.

    Move the SysMailFactory::getNonInteractiveMailer().sendNonIntercative(mailer.getMessage()) inside the while select and check.

    Thanks,

    Girish S.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,969 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,842 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans