BAQ Export Process Dynamic File Name

I’m a newby to BAQ’s. Have created a nice simple grid to export to a csv file for further analysis. Runs every day (stock status). Problem is the BAQ export process overwrites the previous file. I’ve tried the usual suspects to assign a dynamic file name, but no luck…

%time%_stock_status.csv create a file with exactly that name, '%time%_stock_status.csv
Thought maybe I’d slip some SQL in there…
GETDate().csv, %Getdate().csv
All kinds of variation in the Output filename field. It doesn’t recognize any wildcards I’ve tried.

Is there a way to dynamically create file names, or have Epicor not overwrite the previous file?

Thank you.

You can find a lot of posts related to exporting BAQ and making the name uniquqe in some way.
e.g. Batch file to run BAQ Export Process - #6 by bordway

I don’t think there is anything in the stock processes.
I typically use simple .BAT files and Windows Task Scheduler to move/copy/rename.
Low tech but works for me.

I’ve thought a BPM might work too but not acutally tested anything …yet.
Also, I believe others are using MS SQL to export data, handle file naming, etc…

thank you. much appreciated. I think I’m going to write a Windows batch file. Epicor can be a bit user hostile at times.

DMT only works from PowerShell right now. Your question is about PowerShell and not DMT or Epicor at all.

Here is a PowerShell function for getting an ISO compliant timestamp that is safe for file\path names:

Function ISOFileTimeStamp {
    Return (Get-Date -Format "s") -Replace '[:]', ''
}

It can also be done with a BPM

Under Ice.Proc.DynamicQueryExport.SubmitToAgent (Preprocessing BPM)

  • It took a bit of experimenting but the C# to access the file name is

var row = ds.DynQueryExpParam[0];
string filename = row.ExportFilename;
string exportFormat = row.ExportFormat;

// add Code to change filename - here

row.ExportFilename = filename; // I wrote logic to add the date/time/millisends to the filename - had to remove the extension and put it back in

I can give the complete code but it is clunky and proof of concept but it is operational

1 Like