For this Epicor® tutorial, I wanted to share a tip I have learned while working with a Business Activity Query (BAQ) in Epicor®: how to call a BAQ from Script Editor.
After a BAQ has been created, you can then call the BAQ from code within the script editor inside of a customization, which allows you to access the data the BAQ returns.
Assuming you are familiar with creating a customization, click on the “Script Editor” tab in your customization.
The first thing you must do is add in the necessary assemblies for calling a BAQ. In the menu bar of the customization screen, select “Tools” and then “Assembly Reference Manager” to open a new window. In the lower, right-hand corner of the window, click on the “Add Custom Reference” button.
Select the following DLL files and click on the “Open” button.
Epicor.Mfg.AD.DynamicQuery
Epicor.Mfg.BO.DynamicQuery
Epicor.Mfg.Core.BLConnectionPool
Epicor.Mfg.IF.IDynamicQuery
You will now see your newly added assemblies under the “Custom Assemblies” folder.
After you have closed the window, be sure to add the following using statement to the top of your code:
using Epicor.Mfg.Lib;
Next, you will need to create a “session” variable inside the Script class:
// Add Custom Module Level Variables Here **
Epicor.Mfg.Core.Session session;
Inside the “InitializeCustomCode” method, initialize the session variable using the current form you are customizing:
public void InitializeCustomCode()
{
// End Wizard Added Custom Method Calls
session = (Epicor.Mfg.Core.Session)CustShipForm.Session;
}
Last, in the method where you want to call the BAQ, initialize the “QueryDesignDataSet” and “DynamicQuery” objects, followed by the actual call.
You can pass query parameters in as well.
private void ShipHead_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
{
// Initialize objects
QueryDesignDataSet dataset = new QueryDesignDataSet();
DynamicQuery query = new DynamicQuery(session.ConnectionPool);
// Point the dataset to the BAQ
dataset = query.GetByID(string.Format(“{0}-BAQName”, session.CompanyID))
// Pass in a parameter
dataset.QueryWhereItem[0].RValue = 123;
// Execute the BAQ
DataTable table = query.Execute(dataset).Tables[“Results”];
}
The data is returned in a DataTable to make it easy for you to access.
Have more questions about your ERP instance? At Datix, we’re experts in all things ERP. Contact us today to learn more about our innovative solutions!
Salesforce integration consulting is about more than just finding a partner with experience in integrations.…
Platform: HubSpot Where It Shines: Email marketing - easy to use email lists, automation, and…
Don’t be left behind by neglecting these 2024 manufacturing trends.
With a comprehensive ERP like CloudSuite Industrial (CSI) from Infor, there are countless possibilities for…
An Infor ERP solution isn’t just a temporary fix to today’s issues, it’s an investment…
An Infor ERP can dramatically improve your operations, but with an ERP integration, you can…