BPM to Log BAQ Execution

A couple people asked for a E9 version of this BPM from this thread (Last date when BAQ was used - #4 by jhawt - ERP 9 - Epicor User Help Forum) so I threw one together quick. I have not tested this in production yet, use at your own risk.

This will actually end up being multiple BPM’s depending on what you want to capture. In E10 there are only two methods for DynamicQuery execution (Execute and ExecuteByID). In E9 there are 7 methods on the DynamicQuery BO (Execute, ExecuteByID, ExecuteByIDParametrized, ExecuteDashboardQuery, ExecuteDashboardQueryPaged, ExecuteFreeForm and ExecuteParameterized)

The code should be the same for all methods. For testing I’ve only setup this code on the ExecuteParameterized method as that is what’s called in the BAQ Designer and was easiest.

Starting off with the condition.

The condition is "Number of rows in the ‘IsNotSystem’ query is more than 0. The query just checks to see if the BAQ is a system BAQ or not. The query is;

for each ttDynamicQuery no-lock where ttDynamicQuery.Delivered = no

The action is executed ABL code

The code is as follows;

DEFINE variable sBAQID as character.
DEFINE variable sExecDate as character.
DEFINE variable sExecUser as character.
DEFINE variable sAssmName as character.
DEFINE variable sCompany as character.
DEFINE variable sCallMeth as character.

/* Change Key4 to match the BO method so you know how it was called */
sCallMeth = “EXECUTEPARAM”.

/* Set current date as string*/
sExecDate = string(DATETIME( TODAY, MTIME )).

/* Set calling assembly name and username*/
find first ttCallContextClient no-lock.
sAssmName = ttCallContextClient.AssemblyName.
sExecUser = ttCallContextClient.CurrentUserId.
sCompany = ttCallContextClient.CurrentCompany.

/* Set executing BAQ ID and Username */
find first ttDynamicQuery no-lock.
sBAQID = ttDynamicQuery.ExportID.

/* Create the UD25 row for this execution */
create UD25.
assign UD25.Company = sCompany.
assign UD25.Key1 = sBAQID.
assign UD25.Key2 = sExecUser.
assign UD25.Key3 = sExecDate.
assign UD25.Key4 = sCallMeth.
assign UD25.Key5 = “KEY5”.
assign UD25.Character01 = sAssmName.
assign UD25.Date01 = now.

I’ve set the key4 variable to be changed per BPM this code is added to, so you can see what BPM is firing it. The Character01 field is the assembly that is calling the execute method so you can see where it was called from.

Below is a quick BAQ showing the results.

2 Likes

This was thrown together pretty quick. Let me know if there is anything that could be changed to make it more efficient or useful.

When the BPM is activated, immediately various users get the following error when attempting to save or do some searches:

Business query Execution error.
Please contact your System Administrator

I even set the condition for the BAQ to only execute when my user account calls it.

Found a potential solution here, but this didn’t work either:

@Rick_Bird I don’t have an E9 system to test this in, but this is my latest dated log baq bpm and I know it logged 628K of entries. Maybe it can help you.

log baq 5-5-17.bpm (49.0 KB)

1 Like

Thanks @gpayne this didn’t fix my issue but it exposed, perhaps, the real issue.
So I tested your BPMs in our Test Environment and it worked fine, I even made a few changes and it still worked, no error message in AR Invoice Entry nor Job Receipt to Inventory.
There are slight structure differences but nothing that would really explain it.
So then I copy/pasted your scripts into our Live environment and tested it and I rec’d the error message again. So then I imported your orignal BPMs and I get the same noted error.
So the issue isn’t your nor my BPMs, but some environment setting.
Any idea what that could be? I’m digging but I’m doubtful this will be easy to determine.

@Rick_Bird Can you add a message line to write to the server log what ttDynamicQuery.Delivered is in the live system?

Maybe there is another value to use to not execute on system routines.

If you comment out the UD25 write can you add messages to follow the flow and get some data out of the log? Is the log set to verbose?

1 Like