AutoPrint at a specified time

Hi,
I’m using the Auto Print feature in the standard data directives to automatically email reports. Good thing is that it works. However, I’m trying to email these reports at a specific time such as midnight. Is this possible? And if so, any ideas on how to get started?

How/when does your data directive get fired? You could put the report generation on a schedule. You can set them up in System Agent Maintenance.

You could use the Ice.SysTask table to kick off your data directive. It would have to coincide with another scheduled task, like MRP or whatever task you have scheduled.

I am trying to mass email Sales Order Acknownledgement reports for all orders that have ‘Auto-Print Ready’ in OrderHed checked. This task needs to be done at a specific time such as midnight.

So I need some kind of directive that will allow me access to the report for a specific order number and also the respective customer email address which is in the Customer table. And then with the report and the email address, send an email.

I tried using Auto-Print in the standard data directive so far just to test if it actually sent an email with an attachment of the report. And I did get it to work, but it being a data directive, will only trigger on update. I need something that triggers based on schedule.

Is what I’m trying to do even possible with a data directive? Is there something else I should look into?

image

I imported the UIRpts.SalesAck.dll through menu maintenance and added this. I tried using it and it works if you want to send one massive pdf of all the reports. But there is no feature where I could send a separate email per customer with their respective report.

Do you have the Advanced Print Routing module? APR will allow you to break the report up into smaller pieces and email those.

Another alternative could be to use an Updateable BAQ Directive (BPM that fires when a UBAQ is run) on a UBAQ that you create (The BAQ doesn’t really update anything, just needs to be “updateable” to show up in “Updateable BAQ Directives Maintenance” list). Each row in the UBAQ would detail the specifics of each report/email that needs to be generated/sent. Then you could put the UBAQ on a schedule, and loop through the UBAQ results to send the emails in a BPM. This would require copying/pasting some C# code in the BPM custom code block.

Adam, this sounds a heck of a lot better than what I’m doing right now for twice-daily BAQ reports. Do you have a link handy for that code, or a hint at where I can find it?

Sure Ashley.

Here’s some generic code from a post I can’t find (I’ve changed it to use the ttResults table that is available in the GetList method of a UBAQ Directive). It sends a standard email. This code won’t email a report, but it shows how you can pull in data from a
UBAQ that could be later used to generate/email a report.

//Test Email
	// Email Notification

    // Initialize Actions
    Func<string, string> GetCompanyAddressAction = (CompanyID) => {

      var Company_Row =
        (from sc in Db.SysCompany.With(LockHint.NoLock)
        where sc.Company == CompanyID
        select new { sc.EmailFromAddr, sc.EmailFromLabel }).FirstOrDefault();

      if (Company_Row != null) {
        return string.Format(@"""{0}"" <{1}>", Company_Row.EmailFromLabel.Trim(), Company_Row.EmailFromAddr.Trim());
      }

      return string.Empty;
    };

    foreach(var ttResults_Row in ttResults) {
      // Initialize Variables
      string EmailTO = "aszoka@myemail.com";
      string EmailCC = "";
      string EmailBCC = "";
      string EmailSubject = "";
      string EmailBody = "";
  
  
      if (ttResults_Row != null)
      {    
		if (ttResults_Row.Calculated_neverBeforeOrdered == 1) {

			EmailSubject += "First Article Required. Part: " + ttResults_Row.OrderDtl_PartNum + " Order: " + ttResults_Row.OrderHed_OrderNum;

		}
          
          EmailBody = "";
          
          if(EmailTO != "") {
            // Send Email
            var mailer = this.GetMailer(async:true);
            var message = new Ice.Mail.SmtpMail();
            message.SetFrom( GetCompanyAddressAction("99999") );
            message.SetTo(EmailTO);
            message.SetCC(EmailCC);
            message.SetBcc(EmailBCC);
            message.SetSubject(EmailSubject);
            message.SetBody(EmailBody);
            message.IsBodyHtml = true;
            mailer.Send(message);
          }
       }
    }

In order for you to email your BAQ report, you’ll need to generate a BAQ report from a BPM. I’ve never had to do this, but there’s a few posts on here related to it. E10 - Print BAQReport from C#

Anyway, you can use some of the above code to load in data from a UBAQ to your UBAQ’s GetList method (Found in Updatable BAQ Directives Maintenance), then use that data to generate/email the reports you need.

What are your BAQ reports that you have to do twice-daily? Does a standard report schedule not work? If the report recipients or the report content isn’t dynamic, there’s probably an easier way to automate it than this.

1 Like

Thank you!

The reports tell people they have tasks to complete in ECOs. Currently, whenever a new employee is added to the process, I set the report to recurring, choose the morning schedule, filter on the employee’s salesrep codes, and fill out the email info. Then I repeat for the afternoon schedule. I can’t modify the parameters from System Agent, so I need to delete and recreate to change anything. The reports also run a second time if they don’t all finish generating in two minutes, so I actually have two morning and two afternoon schedules to split them up. I can’t find a way to put the reports on a process set, either.

Phew! Sorry I asked haha, my head kinda hurts. The things we do for reports.

It would have been easier to generate an email notification every time a task was assigned, with a handy link attachment to boot! It would have been spammy, though, and it wouldn’t remind them if they forgot.

If I can simplify the reminder reports down to one process on the schedule, I want to, but there’s a lot here I haven’t messed around with. Dunno when I’ll get to trying it.