Estou precisando criar um dataset customizado para trazer o histórico do processo:
function createDataset(fields, constraints, sortFields) {
var dataset = DatasetBuilder.newDataset();
dataset.addColumn("metadata#id");
dataset.addColumn("metadata#version");
dataset.addColumn("movementDate");
dataset.addColumn("movementHour");
dataset.addColumn("stateSequence");
dataset.addColumn("realDateTime");
dataset.addColumn("previousMovementSequence");
//Cria a constraint para buscar os formulários ativos
var cst = DatasetFactory.createConstraint("metadata#active", true, true, ConstraintType.MUST);
var constraints_ = [];
constraints_[0] = cst;
for(z = 0; z < constraints.length; z++)
constraints_[z + 1] = (DatasetFactory.createConstraint(constraints[z].fieldName, constraints[z].initialValue, constraints[z].finalValue, ConstraintType.MUST));
var companyId = "1";
var datasetPrincipal = DatasetFactory.getDataset("Frm_SCMA", null, constraints_, null);
for (var i = 0; i < datasetPrincipal.rowsCount; i++) {
var processInstanceId = datasetPrincipal.getValue(i, "TxtNumSolicitacao");
var constraints = [];
constraints[0] = DatasetFactory.createConstraint("processHistoryPK.processInstanceId", processInstanceId, processInstanceId, ConstraintType.MUST);
var DatasetHistorico = DatasetFactory.getDataset("processHistory", null, constraints, null);
for (var j = 0; j < DatasetHistorico.rowsCount; j++) {
dataset.addRow(new Array(
datasetPrincipal.getValue(i, "metadata#id"),
datasetPrincipal.getValue(i, "metadata#version"),
DatasetHistorico.getValue(j, "movementDate"),
DatasetHistorico.getValue(j, "movementHour"),
DatasetHistorico.getValue(j, "stateSequence"),
DatasetHistorico.getValue(j, "realDateTime"),
DatasetHistorico.getValue(j, "previousMovementSequence")
)
);
}
}
return dataset;
}