Forums

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

setRequired feature is not auto refreshing

Sravya Vuggina August 30, 2018

I am fairly new to Script Runner Behavior and trying to write scripts with the help on examples available online – I must be missing something very obvious. :)

Based on the value Feature Request Category(FRC), mandatory/ optional settings of Model field must vary.

I have used script runner to dynamically mandate Model when FRC value is “Missing Special Test” and optional when FRC value is “Missing Vehicle Model”.

Model field is getting displayed as optional when Missing Vehicle Model is selected for the first time, but when the value of FRC is switched to Missing Special Test (where Model field is mandatory) and back to Missing Vehicle Model – Model field is not automatically switching to optional.

How to make it optional every time Missing Vehicle Model is selected? 

Here are some screenshots -

1st time.png Expected.png 2nd time.png

 

 

 

 

1 answer

0 votes
Alexey Matveev
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.
August 30, 2018

Hello,

How did you make it required? Did you write code?

Sravya Vuggina August 30, 2018

Yes -  please find my code below.

Should I be exclusively mentioning model.setRequired(false) in the if condition for Missing Vehicle Model? 

 

def category = getFieldByName("Feature Request Category")

def year= getFieldByName("Year")

def make= getFieldByName("Make")

def model = getFieldByName("Model")

def crField = getFieldById(getFieldChanged())

def selectedOption = crField.getValue() as String

 

    if ((selectedOption.contains("Missing Vehicle Model")))

    {

        year.setRequired(true)

        make.setRequired(true)

    }

    else

    {

       year.setRequired(true)

       make.setRequired(true)

       model.setRequired(true)

    }

Alexey Matveev
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.
August 30, 2018

Did you attach this code to the Feature Request Category? I mean, you added the Feature Request Category to your behaviour and added this code in this field?

Sravya Vuggina August 30, 2018

Yes I did. Mapped to the Feature Request Category field and the project / Issue Type. 

Sravya Vuggina August 30, 2018

Added a line of code model.setRequired(false) to the if condition -first case and it seems to be working fine now. No matter in what order Feature Request Category values are selected the behavior of Model field seems to be working as expected. :) 

Alexey Matveev
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.
August 30, 2018

Good to hear! :)

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Atlassian Community Events