Custom Data Model - is there a possibility to connect to the mysql db by a script task (js)

cancel
Showing results for 
Search instead for 
Did you mean: 
patrickeixner
Member II

Custom Data Model - is there a possibility to connect to the mysql db by a script task (js)

Hi together!

I'm trying to get a connection to mysql db by a script task (javascript). Is there any possibility?

My problem with the store entity task is that it is a way too unflexible. I need more dynamic functionality in my process because I have more user tasks with different form und fields. The dynamic dream will be that I have only one script task where I can update all of my variables.

I tried it on this way: (but it says an error -- require not found! Is it because activiti doesn't support node.js?)

var mysql = require('mysql');

var con = mysql.createConnection({
  host: "localhost",
  user: "yourusername",
  password: "yourpassword",
  database: "mydb"
}); 

con.connect(function(err) {
  if (err) throw err;
  console.log("Connected!");
  var sql = "INSERT INTO customers (name, address) VALUES ('Company Inc', 'Highway 37')";
  con.query(sql, function (err, result) {
    if (err) throw err;
  });
});

 

Is there any way to use the data models like this? Otherwise the data models in activiti is not really usable for my complex processes...

Thanks a lot for your informations!

Best regard,

Patrick

2 Replies
jljwoznica
Senior Member

Re: Custom Data Model - is there a possibility to connect to the mysql db by a script task (js)

Have you tried a service task instead? I'm trying to do some research on this for you.

patrickeixner
Member II

Re: Custom Data Model - is there a possibility to connect to the mysql db by a script task (js)

Hi jljwoznica,

thanks for your answer. I will give it a try with the service task.

Thanks,

Patrick