I have been working on a website that will “Start Activity” or “End Activity” for a Job/Assm/Oper and one of the requirements to complete the job is to check to see if a “Data Record” for inspection has been completed. This information is in JobOperInsp and I was wondering if there is a way to query this table via the Epicor API v2. Thanks!
You could create a BAQ to that table and then make a REST call to that BAQ to get the results back… if that works for you?
BAQs is the way to go. Whenever I’m looking for a method to extract data from the system, I always end up calling a BAQ. It’s always easier to just add a new field or change a formula if I want to change something. Have a look at DynamicQuery - below an example from a function:
// define vars
Ice.Tablesets.QueryExecutionTableset tsQET = new Ice.Tablesets.QueryExecutionTableset();
DataSet qryRez = new DataSet();
// CALL DYNAMICQUERY SERVICE
this.CallService<Ice.Contracts.DynamicQuerySvcContract>(dqc => {
// run BAQ
tsQET = dqc.GetQueryExecutionParametersByID("MyBAQ");
tsQET.ExecutionParameter[0].ParameterValue = "Warehouse1";
qryRez = dqc.ExecuteByID("MyBAQ", tsQET);
// END CALL DYNAMICQUERY SERVICE
});
Yes I would be more than happy to use a BAQ in a REST call.
Go to the swagger API and BAQsvc object.
I’m sure there’s a ton of examples on here too.
I have the following… If I don’t stringify the ds variable then I get an error about AsmSeq is required. But when I do stringify the ‘ds’ I get Sorry! Something went wrong. Please contact your system administrator. Is there any chance I have set this up incorrectly or can I get more details about the error from somewhere else? Thanks
let ds = {
'ExecutionFilter': [
{
'ParameterID':"AsmSeq",
'ParameterValue':item.AssemblySeq,
'ValueType':'int',
'IsEmpty':false,
'SysRowID': uuidv4(),
'RowMod':'A'
},{
'ParameterID':'JobNum',
'ParameterValue':item.JobNum,
'ValueType':'nvarchar',
'IsEmpty':false,
'SysRowID': uuidv4(),
'RowMod':'A'
},{
'ParameterID':'OprSeq',
'ParameterValue':item.OprSeq,
'ValueType':'int',
'IsEmpty':false,
'SysRowID': uuidv4(),
'RowMod':'A'
}]};
var myHeaders = new Headers();
myHeaders.append("X-API-Key", this.$apiKey);
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Accept", "application/json");
myHeaders.append("Authorization", `Basic ${this.credentials}`);
console.log("The DS", ds)
var raw = JSON.stringify({
"queryID": "JobOprInspectionsCount",
"executionParams": JSON.stringify(ds)
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://aero-e10ap1-tvl.tectcorp.com/NashvilleERPTest/api/v2/odata/t300/Ice.BO.DynamicQuerySvc/ExecuteByID", requestOptions)
.then(response => response.text())
.then(result => console.log("Dynamic", result))
.catch(error => console.log('error', error));
I recommend following @utaylor’s advice and use the BAQSvc instead of DynamicQuerySvc. It was made to execute BAQs where the DynamicQuerySvc is similar to running the BAQ Designer. All you have to do to execute a query is pass the parameters in on the request.