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

Run IQL (Insight) from groovy

How can we run an IQL statement from groovy? can we use and custom field values in the statement?

1 answer

1 accepted

0 votes
Answer accepted

Where did you want to run this groovy? 
Is this in an insight post-function? or something similar? 

I'm more of a scriptrunner/groovy person. But I'm sure many things are similar.

One thing that's not clear from the Post Function groovy screen is what variables are available in the script by default.

But, we can use the Test Script functionality and examine the built-in variables by running a short script like: "${this.binding.variables}"

This will output something like:

[issue:JSP-1922, object:null, originalIssue:JSP-1922,, currentUser:p6s(p6s)

 Ok, so we know we can use "issue" and get a custom field object... here is a sample script i created to test this:

import com.atlassian.jira.component.ComponentAccessor

def cfm = ComponentAccessor.customFieldManager
def cf = cfm.getCustomFieldObjectsByName('Name of Your Custom Field')[0]
def cfValue = issue.getCustomFieldValue(cf)

IQLFacade iqlFacade = ComponentAccessor.getOSGiComponentInstanceOfType(IQLFacade)

If you need help writing groovy script, searching for "scriptunner" and what you're trying to do I the community will yield TONS of results.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira Service Management

Atlympic Event: Jira Service Managemnt

Hello Community!  Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...

91 views 0 1
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