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 retrieve a value base when value selected from DB picker field?


I created a DB picker field "Location Name" which displays all locations from a drop-down field. That is working fine, we are using it for multiple projects.

For a new project, we would like to do some automation. We would like to retrieve a person's name to a text field if a location is selected from the DB picker field. We have accounts from different locations and multiple locations are assigned to a person. for example, we have 5 Reps and each rep are assigned 10 locations. So when the user is creating an issue and selecting a location from the DB picker drop down it should add the person to the text field (Representative) that belongs to that location.

The below listener script works fine with Jira custom fields but it is not working with the DB picker field. I mean instead of DB picker if I use a text field and type that location name that exists in the database it'll pull up the rep name, but for some reason, it's not working with the ScriptRunner DB picker field.

Any idea how I can make it works?

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.db.DatabaseUtil
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder

def event = event as IssueEvent
def issue = event.issue
def customFieldObjects = ComponentAccessor.customFieldManager.getCustomFieldObjects(issue)

def locationName = customFieldObjects.findByName("Location Name")
def rep = customFieldObjects.findByName("Representative")

def value = issue.getCustomFieldValue(locationName)

DatabaseUtil.withSql('Mysql_Accounts_DB') { sql ->
def row = sql.firstRow("""SELECT customer_id, LocationName, AssignedRepPerson, AssignedRep_id
FROM Accounts WHERE LocationName = ?""", value)
if (row) {

rep.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(rep), row.'AssignedRepPerson'), new DefaultIssueChangeHolder())

Thank you

0 answers

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events