Create
cancel
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

How do I use Database Picker with custom pickers

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 Confluence Cloud

🎨 Add some visual life to your templates

Hi Atlassian Community, My name is Avni Barman, and I am a Product Manager on the Confluence Cloud team. Based on feedback from you, we are giving admins more power to create templates that a...

129 views 1 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