Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Determine the cascade field

arno
Contributor
July 16, 2023

Hi All

I recently needed to determine the value of a cascade field to automatically assign handlers, which I learned could be done through Scriptrunner, but I found that the script I wrote was not successful,The specific code is as follows


import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.customFieldManager
def Platform_field = customFieldManager.getCustomFieldObject('customfield_13768')
def Platform = issue.getCustomFieldValue(Platform_field).toString()
def mail = ''
if (Platform == 'test'){
   mail = 'arno@test.com'
}else if (Platform == 'test1'){
   mail = 'addy@test.com'
}
def user = ComponentAccessor.userManager.getUserByName(mail)
issue.setAssignee(user)

I know that the cascading field belongs to the map type, is there a problem with my conversion method? If I get the field of the selection list (single selection), the above code can work normally

1 answer

0 votes
Nic Brough -Adaptavist-
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.
July 17, 2023

The problem with your code is that you are not reading the name of the option.  Casting a single-select to a string is not the right way to do it, but it will work because options have been coded in a way to let it work.

Cascading select options have not, because they can't be.  You'll need to use "getName()" to extract the name of the option.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events