Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,361,143
Community Members
 
Community Events
168
Community Groups

How to pass parameter into JQL query string in scriptrunner

Hello everyone

I want to set parameter to "assignee" into JQL query string.

I tried but there is no result .

Code below that

----------------------------------------------------------------------------------------------

def slYetkilisiCF = customFieldManager.getCustomFieldObject("customfield_15655")/
def slYetkilisiValue = issue.getCustomFieldValue(slYetkilisiCF)

final jqlSearch = 'assignee = '+slYetkilisiValue
def parseResult = searchService.parseQuery(user, jqlSearch)

Query query = parseResult.getQuery();

------------------------------------------------------------------------------------------

When I executed, get output below;

log.debug(query)->{assignee = c0566(JIRAUSER56893)}

Output is wrong query because (JIRAUSER56893) is extra in string.

It should be assignee = c0566

 

How I pass parameter into JQL query string in script runner?

Thanks for your support.

2 answers

2 accepted

1 vote
Answer accepted

To add on, what you are passing into the jqlSearch is the ApplicationUser object which gives you: username(userKey)

What you need is just the username which you can get using the method .getName() or .getUsername()

See this API documentation of ApplicationUser for more information. 

Moving forward, you can use something like variable.getClass() or slYetkilisiValue.getClass() to check the object type and read on their respective method in their documentation. For example, a String variable will return "class java.lang.String". 

Thanks for your support it is working now.

1 vote
Answer accepted
Hana Kučerová Community Leader Mar 16, 2021

Hi @oytun_cayli_man_eu ,

has your custom field type User Picker (single user)?

If so, please try to do: 

final jqlSearch = 'assignee = '+slYetkilisiValue.getName()

I believe slYetkilisiValue is ApplicationUser object, so you need to get name from it.

Thanks for your support it is working now.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

Apps for Confluence you won't want to miss: RSVP for September's Appy Hours

Calling all collaborators and Confluence users! Our Appy Hours event on September 29th features 4 presenters demoing functionality to superpower Confluence. Don't miss learning about these apps i...

120 views 0 9
Read article

Atlassian Community Events