Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

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!


using currentuser in database pickup confuration script is not working


select jiraaccount,displayname from mcigeneralname where jiraaccount = ?

search sql

select jiraaccount,displayname from mcigeneralname
where lower(jiraaccount) like lower(?) || '%' 


configuration script :

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.customfields.option.Option
import com.onresolve.scriptrunner.canned.jira.fields.editable.database.SqlWithParameters
import com.atlassian.jira.component.ComponentAccessor;

def userinfousername = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().getUsername()
String userinfo = userinfousername

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

new SqlWithParameters(
"select jiraaccount,displayname from mcigeneralname where jiraaccount like ? || '%' and jiraaccount = ?",

getValidationSql = { String id, Issue issue,String originalValue ->

new SqlWithParameters("""
select jiraaccount,displayname from mcigeneralname
where displayname = ? and jiraaccount = ?
, [id, userinfo])


when userinfo variable set to a string it works but when the current user is passed to the script it's not working

for example userinfo = 'm.moeini'

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 26, 2023

Hi @mohammad moeini

After going through the code you shared above, I have a question: i.e. can you confirm that the displayname column matches the Username instead of the User's Display Name? 

If not, instead of using:-

def userinfousername = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().getUsername()

it would be better if you used:-

def userinfousername = ComponentAccessor.jiraAuthenticationContext.loggedInUser.displayName

Also, I suggest upgrading your ScriptRunner plugin to the latest release so you can use the HAPI feature to simplify your code.

For the sample above, when using HAPI, all you need to do is:-

import com.adaptavist.hapi.jira.users.Users



I am looking forward to your feedback and clarification.

Thank you and Kind regards,


AUG Leaders

Atlassian Community Events