Hola Alguien tiene un ejemplo de como recuperar la versión X de un formulario vía Dataset?
Lo hice consultando a la base de datos directamente pero no me deja filtrar por dos campos que necesito.
Adjunto ejemplo:
function createDataset(fields, constraints, sortFields) { var newDataset = DatasetBuilder.newDataset(); log.info("QUERY: " + myQuery); var dataSource = "/jdbc/FLUIGPRDSQL"; var ic = new javax.naming.InitialContext(); var ds = ic.lookup(dataSource); var created = false; var filtro = "";
if(constraints != null) {
for (var i = 0; i < constraints.length; i++) { // AQUI VOCÊ TRATA O FILTRO if (constraints[i].fieldName == "c_periodo_actual") {
filtro += " and A.c_periodo_actual = " + constraints[i].initialValue; }
if (constraints[i].fieldName == "c_emp_evaluado") {
filtro += " and A.c_emp_evaluado like UPPER('%" + constraints[i].initialValue + "%')"; }
} }
var myQuery = "select * from ML001017 A LEFT JOIN DOCUMENTO AS B ON B.NR_DOCUMENTO_PAI = A.cardid AND B.NR_DOCUMENTO=A.documentid where B.VERSAO_ATIVA=1 AND B.LOG_DELETE=0 and A.version = 2000 and A.c_estado !='Cancelada'"; myQuery += myQuery + filtro;
myQuery = myQuery.toUpperCase(); log.info("#### SQL GERADO"); log.info(myQuery);
try { var conn = ds.getConnection(); var stmt = conn.createStatement(); var rs = stmt.executeQuery(myQuery); var columnCount = rs.getMetaData().getColumnCount(); while (rs.next()) { if (!created) { for (var i = 1; i <= columnCount; i++) { newDataset.addColumn(rs.getMetaData().getColumnName(i)); } created = true; } var Arr = new Array(); for (var i = 1; i <= columnCount; i++) { var obj = rs.getObject(rs.getMetaData().getColumnName(i)); if (null != obj) { Arr[i - 1] = rs.getObject(rs.getMetaData().getColumnName(i)).toString(); } else { Arr[i - 1] = "null"; } } newDataset.addRow(Arr); } } catch (e) { log.error("ERRO==============> " + e.message); } finally { if (stmt != null) { stmt.close(); } if (conn != null) { conn.close(); } } return newDataset; }