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

Scriptrunner: Scripted Field JQL using a value from the current issue

Dirk Ronsmans May 13, 2019

I'm trying to use a scripted field (Adaptavist Scriptrunner) Issue Picker.

I would like this field to use a JQL that is based on a value from within the ticket that the field is on.

Couldn't really find anything regarding this (whether I can use a dynamic JQL or if this needs to be scripted) in the documentation.

3 answers

0 votes
Erik Buchholz
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 Leaders.
February 18, 2021

Hi @Dirk Ronsmans ,

I found a solution from scriptrunner documentation

https://scriptrunner.adaptavist.com/6.5.0-p5/jira/behaviours-conversions.html

and the hint at issue picker field configuration

JQL that the issue picker will select from. Leave blank to allow any issue
You can modify this with Behaviours using field.setConfigParam('currentJql', '<your jql query>')

My problem was, that Behaviour does not work on view screen but I can edit the field on view screen.

After I added a server sided script in a Behaviour I saw that the edit screen opens when I tried to edit the field with the server sided script in view screen.

So I added the same script for the issue picker field.

import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField

import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviour

final FormField myFirstField = getFieldByName("My first field")
final FormField mySecondField = getFieldByName("My second field")

final def firstFieldValue = myFirstField.getValue()

if (firstFieldValue) {
mySecondField.setReadOnly(false).setDescription("Select an issue with '${firstFieldValue}'")

mySecondField.setConfigParam('currentJql', '"My first field" = ${firstFieldValue}')
} else {
// selected first field was null - disable control
mySecondField.convertToShortText()
mySecondField.setReadOnly(true).setDescription("Please select my first field before entering the issue")
}
0 votes
Alexander Bondarev
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 Leaders.
May 13, 2019

Also you can write on Adaptavist`s support - they have an excellent team!

0 votes
Alexander Bondarev
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 Leaders.
May 13, 2019
Dirk Ronsmans May 13, 2019

Thanks for the feedback.

Doesn't look like it's entirely the same question but similar enough to piece together a solution!

Erik Buchholz
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 Leaders.
February 18, 2021

Hi @Dirk Ronsmans ,

did you find a solution for this?

We have exactly the same requirement like you.

Regards
Erik

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events