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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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 do I use Database Picker with custom pickers

Brian Ho I'm New Here Sep 18, 2020

I am trying to use the Database Picker custom field to present a drop down single-selection list for my users to choose 1 approver to remove at a time and associate a justification of removal for each. I have the following query set in the Search SQL field:

select cfv.id, upper(app_user.lower_user_name), issue
from customfieldvalue cfv
JOIN app_user on app_user.user_key = cfv.stringvalue
where customfield IN ( select id from customfield where cfname = 'Approvers' ) and app_user.lower_user_name like ? || '%'
;

The problem is that it's returning the full list of Approvers from all my tickets, whereas I am trying to only return the approvers for the issue that the field is on. 

I've tried the customizations, but it did not appear to have any effect:

import com.atlassian.jira.issue.Issue
import com.onresolve.scriptrunner.canned.jira.fields.editable.database.SqlWithParameters

getSearchSql = { String inputValue, Issue issue, String originalValue ->

// return SqlWithParameters, that will control the search SQL..., eg:
new SqlWithParameters("select cfv.id, upper(app_user.lower_user_name), issue " +
"from customfieldvalue cfv " +
"JOIN app_user on app_user.user_key = cfv.stringvalue " +
"where issue = ? and customfield IN ( select id from customfield where cfname = 'Approvers' ) and app_user.lower_user_name like ? || '%';", [issue.getId() , inputValue])
}

Either method does not change the results and outputs the complete list of approvers from all issues.

Any help would be greatly appreciated. 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Jira Cloud Performance Improvements

Hello everyone, I am a product manager in the Jira Cloud team focused on making sure our customers have a delightful experience using our products. Towards that goal, one of the areas which is extr...

175 views 2 9
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