function createDataset(fields, constraints, sortFields) {
	
	var dataset = DatasetBuilder.newDataset();
    dataset.addColumn('Success');
    dataset.addColumn('Message');

    
    var parameters = {
    	userId: '<user_id>',
    	substituteId: '<substitute_id>',
    	validationStartDate: '02/02/2020',
    	validationFinalDate: '02/02/2020',
    	process: '<process_id>',
    	metodo: 'insert'
    };
    
    if(constraints != null) {
        for(var i = 0; i < constraints.length; i++) {
        	parameters[constraints[i].fieldName] = constraints[i].initialValue;
        }
    }
    
	var clientService = fluigAPI.getAuthorizeClientService();
	var gson = new com.google.gson.Gson();
	
	log.info("service" +clientService );
	
	
	try {
		
		//INSERT
		if(parameters.metodo == 'insert'){
			
			log.info("ENTROU NO INSERT");
			var data = {
		        companyId: getValue("WKCompany") + '',
		        serviceCode: 'createSubstitute',
		        endpoint: '/api/public/bpm/substituteUser/create',
		        method: 'post',     
		        timeoutService: '5000',
		        params: {
		        	"companyId": getValue("WKCompany") + '',
			        "userId": parameters.userId,
			        "substituteId": parameters.substituteId,
			        "validationStartDate": parameters.validationStartDate,
			        "validationFinalDate": parameters.validationFinalDate,
			        "processes": [{
			     		"process": parameters.process  
			     	}]
		        }
		    }
			
			log.info("Passou pelo Data" + data)
		//UPDATE
		}else if(parameters.metodo == 'update') {
			
			var dataGet = {
		        companyId: getValue("WKCompany") + '',
		        serviceCode: 'createSubstitute',
		        endpoint: '/api/public/bpm/substituteUser/getAllSubstitute/'+getValue("WKCompany")+'/'+parameters.userId+'/'+parameters.substituteId,
		        method: 'get',     
		        timeoutService: '5000'
			}
			
			log.info("==== Data Get do ds ====");
			log.dir(dataGet);
			
			var voGet = clientService.invoke(gson.toJson(dataGet));
			var resultGet = JSON.parse(voGet.getResult());
			
			if(resultGet.content != 'ERROR') {
				
				for (var i = 0; i < resultGet.content.length; i++) {
					
					var data = {
					        companyId: getValue("WKCompany") + '',
					        serviceCode: 'createSubstitute',
					        endpoint: '/api/public/bpm/substituteUser/update',
					        method: 'post',     
					        timeoutService: '5000',
					        params: {
					        	"companyId": "1",
					        	"id": resultGet.content[i].id,
						        "userId": parameters.userId,
						        "substituteId": parameters.substituteId,
						        "viewWorkflowTasks" : true,
						        "validationStartDate": parameters.validationStartDate,
						        "validationFinalDate": parameters.validationFinalDate,
						        "processes": [{
						     		"process": parameters.process  
						     	}]
					        }
					    }
					
					var vo = clientService.invoke(gson.toJson(data));
					var result = JSON.parse(vo.getResult());
					
				}
				
		    } else{
		    	dataset.addRow(new Array(false, resultGet.message.message));
		    }
			
			
		//DELETE
		}else if(parameters.metodo == 'delete'){
			
			var data = {
		        companyId: getValue("WKCompany") + '',
		        serviceCode: 'createSubstitute',
		        endpoint: '/api/public/bpm/substituteUser/remove',
		        method: 'post',     
		        timeoutService: '5000',
		        params: {
		        	"companyId": getValue("WKCompany") + '',
			        "userId": parameters.userId,
			        "substituteId": parameters.substituteId,
			        "validationStartDate": parameters.validationStartDate,
			        "validationFinalDate": parameters.validationFinalDate,
			        "processes": [{
			     		"process": parameters.process  
			     	}]
		        }
		    }
		}else{ //retorno com erro
			var data = {
		        companyId: getValue("WKCompany") + '',
		        serviceCode: 'createSubstitute',
		        endpoint: '/api/public/bpm/substituteUser/remove',
		        method: 'post',     
		        timeoutService: '5000',
		        params: {
		        	
		        }
		    }
		}
		
		
	    var vo = clientService.invoke(gson.toJson(data));
		var result = JSON.parse(vo.getResult());
		
	    if(result.content == 'ERROR'){
	        dataset.addRow(new Array(false, result.message.message));
	    } else{
	        dataset.addRow(new Array(true, 'Sucesso'));
	    }
	}catch(e){
		dataset.addRow([false, e.toString()]);
	}

    return dataset;
}




