Missed Team ’24? Catch up on announcements here.

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

Scriptrunner Behaviour om a cascading select list field

Marco Brundel
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 12, 2021

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

2 answers

2 accepted

0 votes
Answer accepted
Marco Brundel
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.
June 24, 2021

Hi,

I've got it working with the following script in the behaviour

 

import com.atlassian.jira.component.ComponentAccessor def customFieldManager = ComponentAccessor.getCustomFieldManager()def cfield = getFieldByName("Assignment Group (Cascading)")Map mapValue = cfield.getValue() as Mapdef value1 = mapValue.get(0).toString() getFieldByName("Standaard Change").setConfigParam("currentJql", "issuetype = 'Test Case Template' AND status = Active AND summary !~ Rollback AND cf[14207] = \"" + value1 + "\"")
0 votes
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 13, 2021

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

Marco Brundel
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 25, 2021

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
AUG Leaders

Atlassian Community Events