Need to send email based on a BAQ, on a regular interval, How to proceed?

,

Would using the BAQ Export Process work for you? You could export the report daily…It is new to me but I think you can set it up to run regularly.

I do this all the time using a UBAQ.
Write a BAQ which returns the data / records you want to email
Then on Post Processing BPM On GetList (On the UBAQ) do the emailing.

foreach(var x in ttResults)
{
 var mailer = this.GetMailer(async: true);
  var message = new Ice.Mail.SmtpMail();
   var from =    "internal@account.com";
   message.SetFrom(from);
   var to =   x.Calculated_EmailAddress;
   message.SetTo(to);
   message.SetSubject("Statement and Invoice");
   var body =  "Statement and Invoice Attached";
   message.SetBody(body);
   mailer.Send(message);
}
5 Likes

BAQ report on a schedule + APR would be perfect for this

3 Likes

While APR would make this much more versatile, it’s not even needed.

Bare bones approach:

  1. Create the BAQ
  2. Create the BAQ Report (must have a date field option tied to you “< 30 days”)
  3. Create the System Agent Schedule
  4. “Print” the report using:
    a. Select the schedule you created in step 3, and check the Recurring box
    b. Select the date field to be Dynamic, and Today
    image
    c. Select the “email/Fax” tool
    image
    d. Fill in the required info. This info will be static (future emailings use it as well)
    e. Hit OK in the SSRS Email/Fax window.

You will now have a scheduled task that will run the BAQ report and email it based on the values you entered in step 4.

Note that the address fields email body will be the same for all future scheduled events. If you need it to be dynamic (set the TO:, Subject, or Body basedon the reports contents, you’ll need APR.

EDIT

Just to be clear, this method is best for internal mailings, as you cannot change the receipients list. In fact, to make any changes, requires deleteing the scheduled task, and starting over from scratch.

I use this method for “reminder” type reports. Things like “Open PO with bad Expense Acct”, “Arrived but not Received” (for receipts that weren’t properly received), “Incomplete Order Info” (for when any line description contains “TBD”), etc …

8 Likes

Thanks Calvin,

It is indeed sent to the same email address which is a email Group, so whoever is part of it will receive it. so no need to change it here…

I like the idea of a report (because it is a listing of multiple row info… ) while an email I am not sure if I can design it with HTML to make it look nice… But will try Jose’s proposal as well…

You mention at point 2: "must have a date field option tied to you “< 30 days” "
What you mean? 'cause my BAQ is already setup to retreive the rows with the date less than today + 30 days…
Do you mean an optional parameter for the report?

Thanks all for your replies!

I will test this this morning.

1 Like

You cannot use HTML in the “Email/Fax” type printout.

If your BAQ’s date criteria is based on “TODAY”, then no you don’t need to have that parameter passed to it from the BAQ Report option field.

Just make sure that you consider the schedules date and time for what “today” will evaluate as.

I have several scheduled BAQ Reports that take in a date as a parameter, and are on a schedule that runs at 12:01 AM. For these I have to set the data parameter as Dynamic, with the dynamic value of “Yesterday”. So when it runs at 12:01 on 11/5, the BAQ uses a date of 11/4.

You could just set you schedule to run at 11:59 PM, but then run the risks of it not actually starting until the next day, or that transactions happened between when it ran (11:59 PM) and the next day.(12:00)

edit

One more thing… If you select the output type (PDF, Excel, XML, etc…) that the attachment (the BAQ Report) will be. Most of mine are in Excel Data Only format.

1 Like

Thank you Calvin.

I am a bit confused about the Print (your point4)
I have created a schedule to run every Monday.
How do I setup the print? Do I need to create a menu item ?

A menu item would be handy for running the BAQ Report whenever you want. But you can actually run and/or schedule it from BAQ Report Designer, via Actions -> Test Report Form

image

Then in the Report “print form”

  1. Select your schedule
  2. Check the recurring box
  3. Enter a description - this makes it easier to ID in the Task Scheduler
  4. Click the Email button

image

Fill in the SSRS Email window. I always bcc myself, then I’ll know its working (and when its not).

NOTE: Hitting the Enter key while in any field in that SSRS Email window is the same as clicking “OK”. To make line breaks in the Body, use Ctrl+Enter.

Click OK, and then it should appear in the scheduled tasks

2 Likes

OK thanks Calvin, it all worked finally…:+1: but also tks for the Ctrl-Enter mention…
I did multiple tests…and now… well they all show in my tasks list to be proceed tonight at 12h40.

This morning I received all the emails tests I created…

How do I delete them in order to create just one…with a meaningfull email body text… (because, yes, I did press Enter for a new line and it closed the window… :thinking:)

Thanks

Pierre

1 Like

To delete, either

  1. Open the System Monitor and select it on the Schedule Tasks tab, and hit delete (you might have to use the delete icon on the toolbar).
  2. Open System Agent maintenance, find the schedule you selected, and then the task. Select the task and delete it.

Adding the User Description when “printing” saves you from having to guess which task is which. I can’t recall what the highlighted BAQ Report is below (LOL)

image

1 Like

Tks Calvin…good suggestion.

:hugs:

Is there a method that would allow me to select my BAQ report and use the dynamic date option and allow the user to specify a date add expression? For example, I want to report on any orders that have a ship date less than or equal Today + 15 days.Next15-DayOrderReport

If you scheduled that report to run every day at 11:00 PM (and recurring) - with the settings you’ve shown - it would run the BAQ report, every day.

When the scheduled fires today (11/7) at 11:00 PM, the BAQ would be passed the date of 11/22, via your “Ship By” option.

When the scheduled fires tomorrow (11/8) at 11:00 PM, the BAQ would be passed the date of 11/23, via your “Ship By” option.

And so on until you delete the scheduled task.

My report was erroring out. So can I assume that the Today + 15 is a legitimate argument variable? Should I assume that the issues lies within the BAQ? I always want to be looking out a number of days based on user input. I did not want to hard code a set number of days in the BAQ.

Was the error “No records selected”? If so, then you might have the logic backwards on your BAQ Report designer.

One more thing … If your BAQ is looking at the ReqDate (aka: Ship By Date) in the releases, they can be blank. When they are blank, the system looks up a level to the order line. and if that’s blank then the OrderHed.

So you might want a calc field that check if the OrderDtl.ReqDate is null. If So, assign it the OrderDtl.ReqDate, and if that is null then the OrderHedReqDate.

1 Like

One last note about the emailing… I was not so far successful at generating an email body that is formatted. (forget about HTML… just having CRLF working…)

I even tried to create the text using my NotePad++ where I could see the special characters…
Copy paste in the body… and still receive

Hello,This is an email for the bblablabla
instead of

Hello,

This is an email for the blablabla

Is there a way to make this work? I can see this not being a priority from the designers but I feel it is the same issue as the text box where we need to replace CRLF with VBcrlf …

if so How would that be done here ? emailing recusively a BAQ report?

Anyone ?

If it is not possible…well I will definitly open a feature request for this non-sense !!!

Thanks

Pierre

I’m not seeing the same thing. Here’s a screen shot of the Email setup window just prior to hitting OK

And here’s what I received in Outlook

image

Yes … it is Outlook 2007 (please don’t judge).

Wow there is hope…

What version are you on??? We are on 10.2.300.11…

That was in 10.1.400. I’ll test in test in 10.2.300 …