BAQ Export trigger in dashboard

Hello,

I’m quite new with epicor and may be some one something like that have already done. So users want to have an updatable dashboard for their everyday work. In dashboard they have updatable fields where they can mark lines as “Done”, when the need arises they want collect all lines marked as “Done” and export in csv. I know that standard way would be to use BAQ export, but it is a scheduled process so it is not the best option. So is there a way to assign this function to a custom button in dashboard which would trigger BAQ export.
I should mention that I’m not strong in deep coding, but if it’s more or less basic, then I can handle that.

Hi Justas,
You are diving in deep with this one for your first time! Welcome to the community. I run custom actions from my custom dashboards all the time! I think this CSV export can be done pretty easy, though I have not tried it myself. This will take some code. But you should be able to copy/paste it most of it. I am not sure your level of experience, so feel free to ask any pointed questions.

Open your dashboard in Customization mode. Go to Tools >Toolbox, and use the toolbox to add a button to your dashboard. Use the properties to change the name of the button to something useful and unique like btnExportCSV. You can also edit the text of the button to change what shows to the user.

Now go to The Event Wizard, find your button with the provided drop downs, and choose the Click event. Click the little right arrow to add it to the list of events, then click Update Selected Event Code. This just drops a little bit of code in your script that gives you an outline for a button. Go to Script. Scroll down to the bottom of the code. There you should see your button click function. Whatever you put inside the code block will happen when you click the button. Inside the function code block put something like:

// Run custom code in BPM
oTrans.PushStatusText("Running Custom Action...", false);

var edv1 = oTrans.Factory("V_YourBAQ_1View"); //You can copy this name from your grids EpiBinding. Go to Properties > EpiBinding. Copy that text and paste it here.

BAQRunCustomAction(edv1, "CustomActionName"); // The name of the custom action you saved in your UBAQ.
oTrans.PushStatusText("Done!", false);

The custom action in your UBAQ, just needs to export the rows you want to CSV. The function BAQRunCustomAction is not built-in to epicor. Someone on this forum gave me this bit of code and I ahve been using it for a couple of years. Just add it below your button code block.

private void BAQRunCustomAction(EpiDataView iEdv, string iActionID)
{
BAQDataView BAQView = (BAQDataView)iEdv;
Assembly assembly = Assembly.LoadFrom("Ice.Lib.EpiClientLib.dll");
Type t = assembly.GetType("Ice.Lib.Framework.BAQUpdater");
BindingFlags bf = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy;
MethodInfo mi = t.GetMethod("BAQRunCustomAction", bf);
object[] param = new object[] { BAQView, iActionID};
mi.Invoke("Ice.Lib.Framework.BAQUpdater", param);
}

Make sure to go to Tools > Test Code before you save to make sure there are no errors. You can see the list of errors in the Script Editor window at the bottom. Test the code, Save the customization, and close it and reopen it to test it out!

This should be enough to get you into trouble. Good Luck!
Nate

Another option would be just to right click on the dashboard grid view and ‘Copy to Excel’ which will open up excel with the data or ‘Copy All’ or ‘Copy All Including Labels’ and paste it into excel.
Once in excel if you need it in CSV comma separated format then from Excel you can save it as a .CSV file.

@NateS Wow, thanks, that’s much more than I expected. I know that allways there is an option to copy data from grid, but coding is more chalenging. By analyzing code I can learn a lot more than just playing around with default functions :slight_smile: