In an effort to reduce duplicated work, I want to see if there is a way to use a javascript variable and have it passed/used as part of the select statement in the dataset open method?
On the report's Initialize method, I have the following javascript:
var now = new Date();
var begin_shift = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0);
begin_shift.setHours(begin_shift.getHours() -7);
var end_shift = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0);
end_shift.setHours(end_shift.getHours() +5);
So instead of replicating the same date/time calculations in SQL, I'd like to pass the date the javascript generates into the open method for the main data set:
maximoDataSet = MXReportDataSetProvider.create(this.getDataSource().getName(), this.getName());
maximoDataSet.open();
var sqlText = new String();
// Add query to sqlText variable.
sqlText = "select workorder.wonum, workorder.description, workorder.worktype, workorder.changedate "
+ " from workorder "
// Include the Maximo where clause
+ " where " + params["where"]
+ " and workorder.changedate < end_shift "
+ " and workorder.changedate >= begin_shift "
;
maximoDataSet.setQuery(sqlText);
I tried to use the
reportContext.setGlobalVariable("begin_shift","end_shift");
, but I got the following error:
Data (id = 407):
+ A BIRT exception occurred: Can not convert the value of end_shift to Date type.. See next exception for more information.
Can not convert the value of end_shift to Date type.
Any ideas?