UBAQ Add New row to External table via C#

Hi guys,

I’m fairly new to writing UBAQ’s.

At the moment, I’m attempting to write a UBAQ that inserts a new row to an external table.

  • First I’m running the BAQ (SELECT statement)
  • Then I’m calling code to add a new row and set the values as one would expect.
DataRow newRow = queryAdapter.QueryResults.Tables["Results"].NewRow();

/* Set values here */

queryAdapter.QueryResults.Tables["Results"].Rows.Add(newRow);

Is there a way I can add a new row without running the BAQ, as the table in question has a lot of data inside which takes forever to view all data, and I don’t need to see existing values.

Thanks!

Maybe you can step back a bit and explain more. Adding the row to the result table would increase the number of records in the BAQ, but would not affect the table that the data came from. When you say external table do you mean a UDTable or a table from a different database that you are viewing through an external BAQ?

Hi Carson,

So I want to add a new row to an external table which is located in an external database.

Seeing as you said the code I have adds a new row to the wrong thing, could you point me in the right direction?

You’ve got two options. If you want this BAQ to be part of a dashboard you will need to create a custom method on the base update method in the baq designer. If you just want to insert the record from the screen, then you would write the C# to do the SQL write in the screen customization. Either way you would not be using any Epicor specific functionality. The only piece that I would suggest pulling from Epicor is store your SQL connection string in a user code or someplace else in Epicor so it’s not hard coded. I would also do the insert by calling a SQL stored procedure and deal with any primary key violations in the stored procedure.