I am trying to execute a query service. The query will change dependant on certain circumstances (what we are searching on).
I figure that there are two ways of doing this:
1) create a different datasource for each query
2) create one datasource and pass it the where clause as a parameter
As I was not sure how to attempt the second one, I tried option 1) first.
The page onload event is the following javascript:
pre
//Set Page Title
var title = localStorage.getItem('category').trim();
console.log("'title = " + title + "'");
(Appery('itemsHeader').text(title));
//Construct service name
var serviceName = title.toLowerCase() + "_items_list";
serviceName = serviceName.trim();
console.log("'Service Name = " + serviceName + "'");
//Execute search service
serviceName.execute({});
/pre
Local Storage "category" = "Beef"
A datasource "beef_items_list" exists with the where clause predefined as {ProductType:"Beef"}
When I load this page, I get the following console output:
pre
'title = Beef' VM2636:208
'Service Name = beef_items_list' VM2636:214
Uncaught TypeError: undefined is not a function VM2636:217
/pre
I am unsure what is causing the error. Also if it is possible to do this with one datasource (passing the where clause as a parameter) can you explain how I would go about this?