Passing a Parameter to an OQL Query inside a Java Action - Parameter ignored

0
I am likely overlooking something, but I have not been able to solve an issue where it seems my OQL Parameter is being ignored. Application Setup 1) I have a Mendix Dataset defined with the following OQL select Location.StateProvinceAbbreviation AS LocationName , Category.Name AS CategoryName , Klass.Name AS KlassName , County.Name AS CountyName , COUNT(Roster.ID) AS InsuredCount FROM Groups.InsuredRoster AS Roster INNER JOIN Roster/Groups.InsuredRoster_Location/PolicyManagement.Location AS Location INNER JOIN Roster/Groups.InsuredRoster_Category/PolicyManagement.Category AS Category INNER JOIN Roster/Groups.InsuredRoster_Klass/PolicyManagement.Klass AS Klass LEFT JOIN Roster/Groups.InsuredRoster_County/Questionnaire.County AS County INNER JOIN Roster/Groups.InsuredRoster_GroupQuestionnaire/Groups.GroupQuestionnaire AS GQ WHERE GQ.ID = $gqa GROUP BY Location.StateProvinceAbbreviation, Category.Name, Klass.Name, County.Name ORDER BY Location.StateProvinceAbbreviation, Category.Name, Klass.Name, County.Name Of note the DataSet has a defined paramter of "gqa"  that the correct entity type. 2) I have a Java Action that is built based on the approach described here (https://github.com/ako/QueryApiBlogPost)  the difference being the parameter.  The following code snippet is what I added in order to add the "gqa"  parameter to the IOQLTextGetRequest IOQLTextGetRequest oqlRequest = Core.createOQLTextGetRequestFromDataSet(this.DataSetName); IParameterMap pm = oqlRequest.createParameterMap(); IMendixIdentifier gqa = this.GroupApplication.getMendixObject().getId(); pm.put("gqa", gqa); oqlRequest.setParameters(pm); IDataTable dt = Core.retrieveOQLDataTable(getContext(), oqlRequest); int colCount = dt.getSchema().getColumnCount(); 3) Finally I have a datagrid on a page that uses a microflow as its datasource that subsequently calls this java action.   - Currently, this approach does not yield any results. - I have debugged the JavaAction and I see that the parameters are "set"  correctly  but when executed the query returns 0 rows - In order to confirm the DataSet, I also added a ReportGrid and ReportParameter to the same page that I am working on and have been able to demonstrate the OQL retrieves valid results.   So the underlying issues seems to be with how I am setting up the parameter in the JavaAction.  Any insight or guidance as to what I am doing wrong or overlooking would be appreciated  
asked
1 answers
0

Hi Welling,

Are you using the OQL module? This module has an action to add a parameter to your OQL query and an action to execute an OQL query. There is a good example on github of a microflow doing this. 

 

Here is the link to the github

https://github.com/ArjenLammers/oqlmodule

 

Here is a link to the module

https://appstore.home.mendix.com/link/app/66876/Mendix/OQL

 

Hope this helps!

answered