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

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

Behaviour Question: Script not rerun when drop-down option is changed

I apologize if this is described somewhere and I've not found it.

I implemented a Behaviour script for setting the linked issue field to be mandatory if the selected Resolution option is "Duplicate". I set up a custom "Resolution with linked Issue" screen that's called during a transition to a step "Completed" that can be selected from All steps in the workflow.

It works fine the first time around after the screen is opened (as part of the transition). The default Resolution is Fixed and when the user changes that to Duplicate, the Linked Issue fields become mandatory. However, when the user changes the resolution values again, the linked issue fields are not set to "not required" as specified in the script.

It appears that the script is only executed after the screen is initially loaded but not if the user changes the Resolution again to something else. 

The script below is in the server side script for the field "Resolution", not the Initialiser script. I tried that as well but it didn't work at all.

Here is the detailed behavior: When the user initiates the transition that brings up the custom "Resolution with linked Issues" screen, the default Resolution is "Fixed". The fields for linked issues ares not mandatory, which is correct.

After I change the resolution to "Duplicate" the fields "Linked Issues" and "Issue" are set to become mandatory. Again, this is correct.

However, when I change the resolution to something else after selecting Duplicate, the linked issue fields *stay* mandatory in spite of the else clause in the script below.

Could somebody please provide guidance on why the script is ignoring the "else" clause when the Resolution is changed after the intial loading of the screen? 

Here is the code 

import com.atlassian.jira.issue.resolution.Resolution

def resolutionField = getFieldById("resolution")
def linksField = getFieldById("issuelinks")
def resolution = resolutionField.getValue() as Resolution

if ( == "Duplicate") {
else {

Thanks in advance for the help and advice!


1 answer

0 votes


It is important where you put the script. You need to add the field Resolution to your behaviour and add the initialize script for the field. I guess you put the script for the whole behaviour that is why it works only when you open the screen.

If you can not figure out where to attach the script kindly attach a screenshot of your behaviour configuration

Alexey, It appears that you're my Guardian Angel in this painful Jira setup for our team. Thank you so much for doing this.

I initially followed the instructions in this article:

It says to put the script into the initialiser function but that didn't do anything. I ended up putting the whole script into the server side script for the Resolution field itself which cases the problems described above.

I also just realized when I set the resolution to Duplicate and add a link I can't submit the form.  I'm about ready to throw in the towel :-(.

Here is the screenshot.


Screenshot of the script itself (located in the serverside for Resolution field:





Thanks so much for your help and patience with a Jira semi-novice.


Your script must be like this

import com.atlassian.jira.issue.resolution.Resolution
import static com.atlassian.jira.issue.IssueFieldConstants.*
import com.atlassian.jira.issue.IssueConstant
def resolutionField = getFieldById(RESOLUTION)
def linksField = getFieldByName("issuelinks")
def resolution = resolutionField.getValue()
if (((IssueConstant) resolution).getName() == "Duplicate") {
else {

Thank you very much, Alexey! A last question: Do I put that into the Resolution field's server side script or as initialiser script?

You put it into the Resolution field's server side script

Thanks, Alexey. Unfortunately, it doesn't work at all with getFieldByName("issuelinks")

And when I change that to getFieldbyId it works initially (it sets the issue link fields to mandatory when resolution "Duplicate" is selected). But I have the same problem I had yesterday that the issue link fields stay mandatory after I change the resolution from Duplicate to something else.

If the script ran again upon change of Resolution (as the Behaviour documentation says) it should set linksField.setRequired(false) but it doesn't. 

Thanks so much for trying to help me with my issues. I really appreciate it. 

My Best


What is the issuelinks field? Is it a custom field you added? What type is it?

It's not a custom field. it's the functional element for the issue links. Here is a good description:

As I said, the script works correctly right after the screen is loaded. It's just not resetting the Required restriction when another value is chosen.

same problem,please , how to resolute?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

460 views 5 18
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