Creating A Custom Scheduled Task Within Epicor

Updated 11/13/2020

Epicor comes with many scheduled tasks - generating PO suggestions, job closing, capture COS / WIP activity, etc. But have you ever wanted to have a task that runs automatically without any end-user intervention? This article describes a little hack that will help you do just that.

Let’s start with an example. As described in this article perhaps you would like to automatically clock out all of your employees at the end of the day. To do that by hand you’d need to pull them up in MES one-by-one and hit the ‘Clock Out’ button. But if you trace out the BO calls you will find there is a fairly simple method you can call to do the work for you. So you wish to loop through all of your clocked in employees and fire off that method as a scheduled process.

So how do we do it? We do it by utilizing a feature of updatable BAQs to override the ‘GetList’ method paired with Epicor’s support to schedule BAQs to automatically run. To start, create a BAQ and make sure you have ‘Updatable’ checked on the General tab:

2020-11-13_15-23-29.png

When it comes to the query builder tab you have two choices:

  1. You can just put a dummy table and fields on there to allow Epicor to accept this as a valid BAQ, with no actual intent on using them within your code. So, for example, add the table ABCCode and the field ABCCode from that table. Epicor is going to throw an error if you try to run a BAQ without having at least one display field, but that doesn’t mean we need to do anything with it.

  2. You can put a meaningful query into the builder that you will utilize within your scheduled task. In my case, perhaps I want to get a listing of all active LaborHed records so that I know who to clock out.

2020-11-13_15-41-48.png

Now we are ready to proceed to the ‘Update’ tab where we will wedge in the code we want to use in our scheduled task. On this tab you want to select the ‘Update Processing’ subtab, check ‘Advanced BPM Update only’, and then press the ‘BPM Directives Configuration’ button:

2020-11-13_15-46-18.png

Within this dialog you want to click on ‘GetList’ from the left-hand tree view and then select ‘New Post-Processing’ from the new button:

2020-11-13_15-48-52.png

At this point you are going to get a typical BPM designer where you can use any of the techniques you typically use. Just note that you also have access to the results of your BAQ via a temp table named ‘ttResults’. Whatever you do within this BPM is going to get called every time that this BAQ is run. You can test it by going to the Analyze tab and hitting the ‘Get List’; button":

2020-11-13_15-44-37.png

And what is really fantastic is that if you use the ‘BAQ Export Process’ (System Management / Business Activity Queries) you can schedule this BAQ to run and your ‘Get List’ BPM will be fired as well:

Screenshot of the Epicor BAQ export process screen - GingerHelp

Looking for some other ideas you could apply this technique to accomplish:

  • Sending monthly statements to customers

  • Custom job closing processes

  • Other automated reports that require some form of parameters applied

I will leave you with one word of warning - there seems to be a variety of circumstances that will cause the custom code on an updatable BAQ to get lost. One in specific is changing the author. So be very careful to keep backups of your code!