Forums

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

The field value is altered to "None" during editing (the Script Runner behavior initializer)

Lakshmi CH
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 18, 2023

Hi Team,

Can anyone please suggest me on this ?

When creating the ticket, I utilized the script runner behavior to align the issue type with the first option in the cascading dropdown list. During the process, I selected both options from the dropdowns in the cascading list (I have attached a screenshot for your reference)

sc1.PNG

Whenever I try to edit the ticket, the second drop-down menu keeps switching back to "None" instead of staying on the selected option (I have attached a screenshot for your reference).

sc2.PNG

Here is the behavior I used Intitilasier. 

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

import groovy.transform.BaseScript

@BaseScript FieldBehaviours behaviours

def issueType = issueContext.issueType.name

def cascadingField = getFieldByName('Cascading Field')

if (issueType in ['Issue Type 1', 'Issue Type 2', 'Issue Type 3']) {

 cascadingField.setFormValue([issueType])

}

1 answer

1 accepted

1 vote
Answer accepted
Tim Perrault
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 18, 2023

Hi @Lakshmi CH 

 

You could make sure that the code only fires on the create step.

 

if (getActionName() = "Create" && issueType in ['Issue Type 1', 'Issue Type 2', 'Issue Type 3'])

 

Something like that. I haven't tested it, but the logic seems sound.

Lakshmi CH
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 18, 2023

Thank you so much@Tim Perrault , It is working now, but small correction. Not 
getActionName() = "Create" , it is (getActionName() in ["Create Issue", "Create"])

 


if ((getActionName() in ["Create Issue", "Create"]) && issueType in ['Issue Type 1', 'Issue Type 2', 'Issue Type 3'])
Like # people like this

Suggest an answer

Log in or Sign up to answer