web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Query is Sending wrong data can you please help !!

(0) ShareShare
ReportReport
Posted on by 2

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

I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    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.

  • Sachin Mittal Profile Picture
    2 on at

    not working sir

  • GirishS Profile Picture
    27,827 Moderator on at

    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.

  • Sachin Mittal Profile Picture
    2 on at

    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
    27,827 Moderator on at

    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.

  • Verified answer
    Martin Dráb Profile Picture
    237,817 Most Valuable Professional on at

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

  • Sachin Mittal Profile Picture
    2 on at

    thankyou it worked

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 512 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 291 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans