The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Use logged-in user as variable

akunnari
August 14, 2020

Hello,

 

I'm trying to configure a dropdown-list, which has specific values depending on the user, who opens it. For this I am using the custom field "Database Picker" which uses a SQL query to get the input from a DB, now to my actual question:

 

I need to write some Script via ScriptRunner for this field, with which I am unfamiliar with. How do I use the "logged-in-User" as a variable? Since I need to use it in the SQL query to select the right content for the dropdown-list...

 

Thanks!

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

1 vote
Answer accepted
Will C
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
August 14, 2020

if you use 

import com.atlassian.jira.component.ComponentAccessor
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

 This will pass you the logged in user as a variable, use .name on the end to pass this variable as a string

TAGS
AUG Leaders

Atlassian Community Events