Boa tarde pessoal, estou tentando fazer um dataset customizado, mas quando uso filtro, da o erro dataset invalido
function createDataset(fields, constraints, sortFields) {
// Criação das colunas de retorno dataset
var datasetRetorno = DatasetBuilder.newDataset();
var tempDataset = DatasetBuilder.newDataset();
tempDataset.addColumn("Id");
tempDataset.addColumn("Nome");
tempDataset.addColumn("Papel");
tempDataset.addColumn("Grupo");
datasetRetorno.addColumn("Id");
datasetRetorno.addColumn("Nome");
datasetRetorno.addColumn("Papel");
datasetRetorno.addColumn("Grupo");
var idC;
var idP;
var id;
var grupo;
var papel;
var nome;
var idF;
var grupoF;
var papelF;
var nomeF;
var filtro_1 = DatasetFactory.createConstraint("workflowColleagueRolePK.roleId", "user", "user", ConstraintType.MUST_NOT);
var filtro_1_1 = DatasetFactory.createConstraint("workflowColleagueRolePK.roleId", "user_interno", "user_interno", ConstraintType.MUST_NOT);
var filtro_1_2 = DatasetFactory.createConstraint("workflowColleagueRolePK.roleId", "admin", "admin", ConstraintType.MUST_NOT);
var filtro_2 = DatasetFactory.createConstraint("active", true, true, ConstraintType.MUST);
var filtro_3 = DatasetFactory.createConstraint("colleagueGroupPK.groupId", "DefaultGroup-1", "DefaultGroup-1", ConstraintType.MUST_NOT);
var filtro_3_1 = DatasetFactory.createConstraint("colleagueGroupPK.groupId", "MEMBER", "", ConstraintType.MUST_NOT);
// Buscando os datasets
var dataset_1 = DatasetFactory.getDataset("workflowColleagueRole", null, Array(filtro_1, filtro_1_1, filtro_1_2), null);
var dataset_2 = DatasetFactory.getDataset("colleague", null, Array(filtro_2), null);
var dataset_3 = DatasetFactory.getDataset("colleagueGroup", null, new Array(filtro_3, filtro_3_1), null);
// A partir do dataset 1 busca todos relacionados no dataset 2
for (var i = 0; i < dataset_1.rowsCount; i++) {
papel = dataset_1.getValue(i, "workflowColleagueRolePK.roleId");
idP = dataset_1.getValue(i, "workflowColleagueRolePK.colleagueId");
for (var j = 0; j < dataset_2.rowsCount; j++) {
idC = dataset_2.getValue(j,"colleaguePK.colleagueId");
nome = dataset_2.getValue(j,"colleagueName");
for (var k = 0; k < dataset_3.rowsCount; k++){
grupo = dataset_3.getValue(k, "colleagueGroupPK.groupId");
id = dataset_3.getValue(k, "colleagueGroupPK.colleagueId");
if(dataset_3.getValue(k, "colleagueGroupPK.colleagueId") == idP){
if(idP == idC){
idF = id;
nomeF = nome;
papelF = papel;
grupoF = grupo;
}
}
}
}
tempDataset.addRow(new Array(idF, nomeF, papelF, grupoF));
if(constraints!=null && constraints.length){ //se tiver constraint filtra
if(constraints[0].constraintType==ConstraintType.MUST) {
if(constraints[0].initialValue==tempDataset[a][constraints[0].fieldName]){
datasetRetorno.addRow(new Array(idF, nomeF, papelF, grupoF));
}
}
} else {
datasetRetorno.addRow(new Array(idF, nomeF, papelF, grupoF));
}
}
return datasetRetorno;
}
}