Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


How to read values from columns of a SQL Query


I'm using the "Resources" option from script runner add on. I've successfully connected to my local database and get rows from a database custom view.

Now I want to read these values to update some custom fields of issues returned in SQL query and re-index these issues, so I could search and find them with filters that use the updated custom fields.


My script is:


import com.onresolve.scriptrunner.db.DatabaseUtil
import org.apache.log4j.Logger
import org.apache.log4j.Level

def log = Logger.getLogger("com.acme.CreateSubtask")

def c_1 = DatabaseUtil.withSql('local') { sql ->
sql.rows('select issue_id,dupu from nc_issues_pusu_v')

log.debug c_1


This script shows in log:


2019-09-25 02:19:59,312 DEBUG [acme.CreateSubtask]: [{ISSUE_ID=10323, DUPU=1}, {ISSUE_ID=10324, DUPU=1}] 2019-09-25 02:19:59,312 DEBUG [acme.CreateSubtask]: [{ISSUE_ID=10323, DUPU=1}, {ISSUE_ID=10324, DUPU=1}]


I want to read row by row and update the custom field "DUPU" with its value for each issue_id.


Please help me.





2 answers

Suggest an answer

Log in or Sign up to answer

Hi @Alejandro Suárez - TecnoFor


Finally, I solved my issue using Script Runner Escalation and Standard Automation combined. No need to update custom fields via DB updates. Thanks for your interest.


0 votes
Alejandro Suárez - TecnoFor
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
Oct 07, 2019

Hi @Tito Vilchez 

I strongly not recommend you to update customField values directly in DB. You can use the jira java api to do this with scriptrunner.

This is because the relations in tables that they have internally and the usage of indexing in Jira.

Check the class CustomFieldManager and update your issues with it.


Maybe i missread the question here. If thats so, could you explain better what do you want to do?



AUG Leaders

Atlassian Community Events