Epicor Functions and BAQs

Is anyone using Epicor Functions to expose BAQs or should we be continuing to use the BAQSvc for this?

?? But why?? Expose how in what context? What’s the use case?

I will run a BAQ in a function then take the resulting dataset, convert to Json, and send the result to the client, who rehydrates it to a dataset, and then uses it in ASP.Net pages. So the only use case I can think of right now is if you don’t want OData.

Should have been more clear. Working on a re-work of an existing integration to utilize functions (hopefully exclusively) and I wasn’t sure if there is a mechanism to call a BAQ from a function .
Otherwise, I’ll need to expose my app to both the function library and the BAQ service, not a big deal just wondering if that’s the way it is

So it does sound like you’re able to call an existing BAQ from a function? Would you be able to share how to? I am sure I’m overlooking something obvious

Sure. I added some logic to version the query, so I’ve left that off. But this is the basic:

1.) Execute Invoke BO

2.) Fill in the Parameters using Fill Table by Query. (This is a single parameter BAQ in this case but you just have to make sure that you’ve filled out all mandatory parameters).

3.) Execute the query using the Invoke BO again

4.) Convert result to json and return using Custom Code. Remember to add your reference for Newtonsoft if you use it!

try {
oResult = Newtonsoft.Json.JsonConvert.SerializeObject(dsQueryResult);
oError = “OK”;
oErrorMsg ="";
catch (Exception e) {
oResult = “”;
oError = “ERROR”;
oErrorMsg = e.Message;

iEmail is my input parameter that I pass to the query and oResult, oError, and oErrorMsg are return variables.


Exactly what I was hoping for, thank you!

Oh, make sure to use the RowMod “A” when filling the parameter table.

1 Like

Aaaaaand, I name any BAQs used in functions with a leading API- because there is no “Where Used” for function calls. But that’s just me…

This is fantastic. Just wondering what happens if you want to return the results as a table, rather than Json?
For instance, I have function ANXStorageReqsGetWHBinsForPart with input parameter of PartNum and response parameter dsAcceptableBins of type Erp.Tablesets.IMWhseBinTableset in which I’d like a list of the available bins to be returned into, do I just to a foreach in the dsQueryResult and insert into the AcceptableBins return dataset?

Unless someone has a better way, I’ve answered my own question. Basically, just insert them as follows:

foreach(DataRow BAQRow in tsBAQQueryResults.Tables[0].Rows)
Erp.Tablesets.IMWhseBinRow NewWhseBin = new Erp.Tablesets.IMWhseBinRow();

NewWhseBin.Company = BAQRow[“WhseBin_Company”].ToString();
NewWhseBin.WarehouseCode = BAQRow[“WhseBin_WarehouseCode”].ToString();
NewWhseBin.BinNum = BAQRow[“WhseBin_BinNum”].ToString();
NewWhseBin.Description = BAQRow[“WhseBin_Description”].ToString();