Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

How to read values from columns of a SQL Query

Hi:

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")
log.setLevel(Level.DEBUG)

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.

 

Regards,

 

Tito.

2 answers

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?

 

Regards

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.

Regards.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

81 views 0 4
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