Hi every body!!!
I wanna know how can I pass parameters to query of Jasper. And How can I create a relation with Servoy and Jasper.
I’m using this on Servoy:
function print(){
var query = ‘SELECT * FROM ORDER E
JOIN COMPANY A ON A.ID_COMPANY = E.ID_COMPANY
JOIN ITEM D ON E.ID_ORDER = D.ID_ORDER
JOIN PRODUT C ON D.ID_PRODUT = C.ID_PRODUT
WHERE E.ID_ORDER = ?
ORDER BY E.N_ORDER ASC;’
var args = new Array();
args[0] = 5
var dataset = databaseManager.getDataSetByQuery(‘crm’, query, args, 100);
foundset.loadRecords(dataset)
plugins.jasperPluginRMI.runReport(foundset, ‘relOrder.jrxml’ ,null, ‘view’,null);
}
It’s don’t work. If I use data base name: plugins.jasperPluginRMI.runReport(‘crm’, ‘relPedido.jrxml’ ,null, ‘view’,null); it’s work, but I want to pass some parameter like de order number.
Sorry, but I don’t know much about programming.
Tanks so much.
Denny,
The jasper reports plugin supports 2 kinds of data sources.
-
a servoy server name.
In this case the report data is retrieved using the sql query defined in the report itself
-
a foundset
in this case, all data (and related data, calculations, global methods) are retrieved from the foundset that is passed in.
Rob
If you use the servoy server name (your second way) you need to do like that:
var params = new java.util.HashMap();
params.put('order_no',5);
params.put('second_param',v_param2); //example of second parameter
plugins.jasperPluginRMI.runReport('crm', 'relPedido.jrxml' ,null, 'view', params);
Then you need to declare these parameters into your jasper report to retrieve them when you generate it.
In the query used in your Jasper report you will use the parameter “order_no” like that:
SELECT * FROM ORDER E
JOIN COMPANY A ON A.ID_COMPANY = E.ID_COMPANY
JOIN ITEM D ON E.ID_ORDER = D.ID_ORDER
JOIN PRODUT C ON D.ID_PRODUT = C.ID_PRODUT
WHERE E.ID_ORDER = $P{order_no}
ORDER BY E.N_ORDER ASC;
Hi!!!
Thanks so much!
I did it and that worked.
Thanks again. ![Wink :wink:]()