Hi.
I’m trying to insert values into a table in postgreSQL, I need to save the values of the variables that the user enters into the application.
I test with static values in this case the test is correct but when I put the variables the script does not work.
The script is the following:
`import groovy.sql.Sql;
import org.bonitasoft.engine.bpm.document.Document;
import org.bonitasoft.engine.bpm.document.DocumentValue;
long idDoc;
idDoc = apiAccessor.getProcessAPI().getLastDocument(processInstanceId, “alfrescoAtCliJeAgPo”).getId();
Document doc=apiAccessor.getProcessAPI().getDocument(idDoc);
DocumentValue docValue=new DocumentValue(apiAccessor.getProcessAPI().getDocumentContent(doc.getContentStorageId()), doc.getContentMimeType(), doc.getContentFileName());
int redAux=1, departamentoAux;
if(red.equalsIgnoreCase(“Sector Rurral”)){
redAux = 2;
}
switch(departamento){
case “Red-1”:
departamentoAux=1;
break;
case “Red-2”:
departamentoAux=2;
break;
case “Red-3”:
departamentoAux=3;
break;
case “Red-4”:
departamentoAux=4;
break;
case “Red-5”:
departamentoAux=5;
break;
case “Red-6”:
departamentoAux=6;
break;
case “Red-7”:
departamentoAux=7;
break;
case “Red-8”:
departamentoAux=8;
break;
case “Red-9”:
departamentoAux=9;
break;
default:
departamentoAux = 1;
break;
}
byte aux = docValue.getContent();
double ordenAuxi = double.parseDouble(orden);
Sql sql = BonitaSql.newInstance(“jdbc:postgresql://localhost:5432/repracionesepemapar”,“postgres”,“bpm”,new org.postgresql.Driver());
sql.execute(“INSERT INTO atencioncliente( id_red, id_deparatamento, orden, cuenta, nombrecliente, telefonocliente, sectorcliente, fechainicio, tiporeparacion, archivoadjunto ,tipoimportancia)”+
“VALUES('”+ redAux +“', '”+ departamentoAux +“‘,’”+ ordenAuxi +“‘,’”+ cuenta +“‘,’”+ nombreCliente +“‘,’”+ telefonoCliente +“‘,’”+ sectorcliente +“‘,’”+ (fechaInicioProceso.toString()) +“‘,’”+ tipoReparacion +“‘,’”+ aux +“‘,’”+ tipoimportancia +“')”);
sql.close();`
Thanks.