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 + "\"")
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 Map
def value1 = mapValue.get(
0
).toString()
getFieldByName(
"Standaard Change"
).setConfigParam(
"currentJql"
,
"issuetype = 'Test Case Template' AND status = Active AND summary !~ Rollback AND cf[14207] = \""
+ value1 +
"\""
)
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:-
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:-
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:-
The Group List example displays the groups available, i.e. jira-administrators and jira-software-users.
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.