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 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
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.

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.

Suggest an answer

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

Bitbucket Smart Commits vs. Genius Commits - What's the difference?

If you already heard about Smart Commits in Bitbucket, know that you just stumbled upon something even better (and smarter!): Genius Commits by Better DevOps Automation for Jira Data Center (+ Server...

106 views 0 2
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