Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

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

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

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!

Leaderboard

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,462,999
Community Members
 
Community Events
176
Community Groups

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:

log.info "${this.binding.variables}"

This will output something like:

[issue:JSP-1922, object:null, originalIssue:JSP-1922, log:com.riadalabs.jira.plugins.insight.services.groovy.GroovyLogger@449654d7, 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
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.IQLFacade

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

IQLFacade iqlFacade = ComponentAccessor.getOSGiComponentInstanceOfType(IQLFacade)
iqlFacade.findObjects(/"Attribute"=$cfValue/)

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
DEPLOYMENT TYPE
SERVER
TAGS

Atlassian Community Events