I am trying to convert a E9 custom execution of a BAQ to E10, however, when I use the E9 code, I got an error. I found solution that say to use parameter instead of the QueryWhereItem ( Calling BAQ from Code Epicor ERP 10 - YouTube ), which I did. I created a new BAQ that uses parameter, but when I tried to execute the BAQ, based on the video link attached, I still get errors.
Can anyone help? If you need to see the actual code that uses the parameter let me know.
Search the site for DynamicQueryAdapter. There are lots of posts on using it to run a BAQ to get back data. There is probably a video also from @josegomez on how to use it out there somewhere.
This is the BAQ: CustomerInfo2A
select
[Customer].[CustID] as [Customer_CustID],
[Customer].[Name] as [Customer_Name],
[Customer].[Address1] as [Customer_Address1],
[Customer].[Address2] as [Customer_Address2],
[Customer].[Address3] as [Customer_Address3],
[Customer].[City] as [Customer_City],
[Customer].[State] as [Customer_State],
[Customer].[Zip] as [Customer_Zip],
[Customer].[EMailAddress] as [Customer_EMailAddress],
[CustCnt].[Name] as [CustCnt_Name],
[CustCnt].[Func] as [CustCnt_Func],
[CustCnt].[EMailAddress] as [CustCnt_EMailAddress],
[Customer].[CheckBox01] as [Customer_CheckBox01]
from Erp.Customer as Customer
inner join Erp.CustCnt as CustCnt on
Customer.Company = CustCnt.Company
and Customer.CustNum = CustCnt.CustNum
cross join Erp.Customer_UD as Customer_UD
where (Customer.CustID = @SelCustomerID)
This is the customized code:
Summary
using (DynamicQueryAdapter baqAdapter = new DynamicQueryAdapter(oTrans))
{
baqAdapter.BOConnect();
QueryExecutionDataSet qds = new QueryExecutionDataSet();
QueryExecutionDataSet qds = baqAdapter.GetQueryExecutionParametersByID("CustomerInfo2A");
qds.ExecutionParameter.Clear();
qds.ExecutionParameter.AddExecutionParameterRow("SelCustomerID", "BAC100", "nvarchar", false, Guid.NewGuid(), "A");
baqAdapter.ExecuteByID("CustomerInfo2A", qds); // THIS IS WHERE IT IS ERRORING OUT
int rCount = baqAdapter.QueryResults.Tables["Results"].Rows.Count;
if ( baqAdapter.QueryResults.Tables["Results"].Rows.Count > 0 )
{
if ( (bool)baqAdapter.QueryResults.Tables["Results"].Rows[0]["Customer_CheckBox01"] )
{
MessageBox.Show( baqAdapter.QueryResults.Tables["Results"].Rows[0]["Customer_CustID"].ToString() + " - " +
baqAdapter.QueryResults.Tables["Results"].Rows[0]["Customer_Name"].ToString() );
}
}
}
Yes, the CheckBox1 field is non-alphanumeric and the CustNum used to join the ither table . I bold them in the BAQ below.
select
[Customer].[CustID] as [Customer_CustID],
[Customer].[Name] as [Customer_Name],
[Customer].[Address1] as [Customer_Address1],
[Customer].[Address2] as [Customer_Address2],
[Customer].[Address3] as [Customer_Address3],
[Customer].[City] as [Customer_City],
[Customer].[State] as [Customer_State],
[Customer].[Zip] as [Customer_Zip],
[Customer].[EMailAddress] as [Customer_EMailAddress],
[CustCnt].[Name] as [CustCnt_Name],
[CustCnt].[Func] as [CustCnt_Func],
[CustCnt].[EMailAddress] as [CustCnt_EMailAddress], [Customer].[CheckBox01] as [Customer_CheckBox01]
from Erp.Customer as Customer
inner join Erp.CustCnt as CustCnt on
Customer.Company = CustCnt.Company
and Customer.CustNum = CustCnt.CustNum
cross join Erp.Customer_UD as Customer_UD
where (Customer.CustID = @SelCustomerID)
Sorry I didnt make that clearer. I mean when you run the query in the editor, do any of your fields have non standard characters - I am specifically curious about < and >. It looks like the xml its trying to deserialize is failing. I would expect that Epicor escapes those but I am just poking to see if it’s related.
Perhaps we could make a simple query, one table, one field returned and one param and see if you get similar results.
Yes, it seems like the data that was coming back is causing the error. I removed most of the fields and only left 2 and everything worked fine.
Thank you.
But how do you escape the data during execution?
Because the error is occurring at the time for ExecuteByID() so I am concluding that I need to escape the data before it is returned to the custom code.
You can create a BPM on the GetList method to loop through the returned data and massage it. However it’s probably best to see if you can find the offending data and fix it.