Create
cancel
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

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

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

Hi @Dirk R_ ,

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

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

Thanks for the feedback.

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

Hi @Dirk R_ ,

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
Community showcase
Published in Jira Service Management

Submit your Jira Service Management use case and win!

Hi everyone - in case you haven’t heard, we’re hosting the show of the century on November 10th: High Velocity: ITSM World Tour.     This virtual, concert-themed experience...

317 views 1 11
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