Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Scriptrunner External Resources. Retrieve, update database

Hello All,

are the tasks below possible in Scriptrunner? Unfortunately, the documentation is very poor it comes to adding to the external database. I am asking for help, unfortunately I am new to Scriptrunner:

  1.  Read/ write SQL in an external database (or Read/ write CSV or Excel)
  2. Conditionnal display of a field
  3. Fill in custom field from external database
  4. Email notifications


Thank you in advance for your help and advices



2 answers

Thank you very much for your answer. I would like to clarify the statement "write SQL in an external database" is it possible to fill in a blank database? e.g. with 

db.executeInsert("INSERT INTO TABLE MyTable VALUES (?, ?, ?)", ['some', 123, myVar])


Sure it would look like this:

def keys = DatabaseUtil.withSql('your_scriptrunner_resource_name'){sql->
sql.executeInsert('INSERT INTO TABLE MyTable VALUES (?, ?, ?)', ['some', 123, myVar])
} "${keys.size()} row(s) were inserted. List of keys: $keys"
0 votes

The DatabaseUtil is only a shortcut to obtaining a groovy.sql.Sql object.

So it's not really their job to document that class.

You'll find that documentation in pages such as: and

But short pointers:

  • To read data, you will probably want to use sql.rows() 
  • To update data, you will use sql.execute()
  • This won't help you with Excel or CSV, for that, you will need to find other methods capable of parsing such files. It is not in scope of scriptunner. But I've had some luck myself using com.opencsv.CSVReader for CSV (never tried to work with excel)
  • Conditionally display a field. Not sure what you want here or how that related to scriprunner resources. To hide fields, you'll generally want to use scriptrunner behaviours.
  • Email notifications are also not relevant in the context of db resources. Notifications are usually the result of workflow postfunctions, scripted listener or scripted jobs.

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events