Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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
Community showcase
Published in Apps & Integrations

Send an Email or Publish to Confluence - What should you do with your release notes?

Background When you hear the words ‘Release notes’, almost always you think of an unsolicited email from a software vendor. But I am here to tell you that from our data, sending release notes via E...

125 views 1 2
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you