Calling a uBAQ in Form Customization Code

I have searched this site, used ChatGPT… tried to find YouTube videos all to no avail. I am trying to wire code in my form customization within an Epicor 10.2.500 instance to call my uBAQ so it will perform the record insert.

I setup the uBAQ as follows:

And tested and validated it will insert a new record (Get New, updated the columns, then clicked Update).

But how to do that using C# I can’t find out. I figure I need to get some dataset, set my values, and then run an update? But how do I get the data set. And is that the right approach?

Thank you for your time!!

As far as I know you can’t trigger a uBAQ to update from C#, unless the uBAQ uses Advanced BPM update and not the default BPM update processing.

1 Like

One of my coworkers told me to ask Grok and it gave me the below code. I just found out that my approach isn’t going to work anyways, so back to the drawing board for me (yay…), but I wanted to share this code template in case it does work and could be of use:

private void btnCreateRecord_Click(object sender, System.EventArgs args)
{
  try
  {
    // Initialize the DynamicQueryAdapter
    DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
    dqa.BOConnect();

    // Execute the updatable BAQ to get the dataset
    dqa.GetByID("Insert_UD14_Log"); // Load the BAQ definition

    // Get a new row (this mimics the "GetNew" operation)
    dqa.GetNew("UD14_Log"); // "UD14_Log" should match the table name in your BAQ

    // Access the dataset and the new row
    DataRow newRow = dqa.QueryResults.Tables["UD14_Log"].Rows[dqa.QueryResults.Tables["UD14_Log"].Rows.Count - 1];

    // Populate the fields in the new row (adjust field names as per your BAQ design)
    newRow["Key1"] = "TestKey1"; // Example: Replace with your actual UD14 field
    newRow["Key2"] = "TestKey2"; // Example: Replace with your actual UD14 field
    newRow["ShortChar01"] = "Log Entry"; // Example: Replace with your actual UD14 field
    newRow["Date01"] = DateTime.Now; // Example: Set current date

    // Update the BAQ to commit the new record
    dqa.Update();

    // Notify the user of success
    EpiMessageBox.Show("New UD14 log record created successfully!");
  }
  catch (Exception ex)
  {
    // Handle any errors
    EpiMessageBox.Show("Error creating UD14 log record: " + ex.Message);
  }
}