Forum Discussion
Hello,
I think you're on the right track by creating a separate server method to perform the query. You can check out this blog post which goes over how to run a query from a Query Definition programmatically. Once you have that method written, you can call that custom method from the REST API by doing a POST request with a URL like the one below. You'll just need to update the bolded part of the URL with the name of your custom method.
POST {base url}/method.RunMyQueryDefinition
{
"my_param" : "my_param_value"
}
You can also pass a body along with this request if you need to pass in any additional parameters into your custom method. This body will turn into the this context item of your custom method. As an example, with the body above, I could add a line like this to my custom method to get the parameter passed in.
this.getProperty("my_param");
Chris
Christopher Gillis
Aras Labs Software Engineer
- Alexandrecimp7 years agoIdeator III
here is the solution :
rest request :
http://localhost/GTSI_I2/server/odata/method.*method_name*
methode :[emoticon:9b06bfad0e6a482e801e5eb8fd9025d6]
Innovator inn = this.getInnovator();
var qry_id = "9D6022A8359748F7BB50AF18F6A41830"; // QD id// get query definition with relationships
var queryDef = inn.newItem("qry_QueryDefinition","get");
queryDef.setID(qry_id);
queryDef.setAttribute("levels","10");
queryDef = queryDef.apply();// execute query
queryDef.setAction("qry_ExecuteQueryDefinition");
queryDef.setAttribute("levels","10");
var res = queryDef.apply();return res;
With this we got all the item type and their dependancy of the database.
Now I need to select only one choosen item type and his dependency.
any idea ?
thanks :)
- christopher_gillis7 years agoCommunity Manager
Hello,
The easiest way to do this would be to add a parameter to your query definition to hold some identifying information about the item like the name. You can then add a condition to your query definition like 'Name = $my_name_param'. This will allow you to filter your query by passing in optional parameters.
In order to add this parameter programmatically, you can get the qry_QueryParameter relationship and set the value of that in order to filter your query. For example,
queryDef.getRelationships("qry_QueryParameter").getItemByIndex(0).setProperty("value", "My Specific Item Name");
If you're new to using parameters with query definitions, I'd recommend checking out the first part of this blog post which goes into more specific steps on how to set up and use a parameter.
Chris