Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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 Behaviour om a cascading select list field

Hi,

I have made a behaviour that, based on the choice in a cascading select list field in an issue-picker field, should only show the issues where the chosen value in the cascading select list field is also filled. (Show in a request type on a JSM portal)

Unfortunately, the behaviour does not work.

 

I have a copy of this behaviour based on a single select field and it works as expected.

 

What is wrong in the “cascading select list field” behaviour script?

Can anyone help me?

Regards, Marco

 

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def assignmentGroup = getFieldById(getFieldChanged()).value

getFieldByName("Standaard Change").setConfigParam("currentJql", "issuetype = 'Test Case Template' AND status = Active AND summary !~ Rollback AND cf[14207] = \"" + assignmentGroup + "\"")

 

 



Screenshot 2021-05-12 at 16.50.46.png

1 answer

Hi @Marco Brundel 

The approach you are taking is not correct.

You should instead use two separate fields. The first will be a List, and the second would be a Text Field which you can convert to a Single or Multi-Select list using the Select List Conversion approach shown in this ScriptRunner Documentation.  In that conversion behaviour, you can include the JQL Query to specify which issues you want to display.

Below is an example working Behaviour code for your reference:-

import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours behaviours
def groupList = getFieldById(fieldChanged)
def groupListValue = groupList.value.toString()

def issuesField = getFieldByName("Issues")

issuesField.convertToSingleSelect([
ajaxOptions: [
url : "${baseUrl}/rest/scriptrunner-jira/latest/issue/picker",
query: true,

data: [
currentJql : "project = TEST and reporter in membersOf(${groupListValue})",
label : "Pick high priority issue in Support project",
showSubTasks: false,
],
formatResponse: "issue"
],
css: "max-width: 500px; width: 500px",
])

Please note, this sample code is not 100% exact to your environment. Hence, you will need to make the required modifications.

Below is a print screen of the Behaviour configuration:-

behaviour_config.png

What this code does is that it uses the Groups list to filter the JQL query and update the options available in the Issues text field, which is converted to a Single-Select List

Below is a print screen of the Custom Field configurations used:-

field_config.png

If you observe the print screen above, the Group List is a Single Select list, and the Issues field is Text Field by default.

 

Below are a few print screens of some test for your reference:-

test1.png

The Group List example displays the groups available, i.e. jira-administrators and jira-software-users

test2.png

When the jira-administrators is selected from the Group List, the Issues list is filtered and displays the issues reported by the users in the jira-administrators group.

test3.png

Next, if the group is changed to jira-software-users, the Issues list options are updated to display only issues reported by users from the jira-software-users group.

I hope this helps to answer your question. :)

Thank you and Kind Regards,

Ram

Hi @Ram Kumar Aravindakshan _Adaptavist_ ,

Thanks for your comment.

This alone does not help me to get my usecase working. In the JIRA my customer uses a cascade selection field (assignmentGroup) and based on the choice made in this cascade selection field, the selection of issues in the issuepicker must be shown. So, only issues with the same assignmentGroup. 

"issuetype = 'Test Case Template' AND status = Active AND summary !~ Rollback AND cf[14207] = \"" + assignmentGroup + "\""

This JQL is working with a normal select field, and i don't understand why this JQL not is working with a cascade select field.

Regards, Marco

Suggest an answer

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

JSM June ask me anything (AMA)

Hello Community members! We’re wrapping up the end of JSM June with an Ask Me Anything (AMA) with the Jira Service Management product team. This is your chance to ask all your ITSM questions to o...

147 views 9 10
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