Making a custom field mandatory based on the value of a fix version

Sunil Mandalika October 15, 2019

My fix version values are 2019-ABC, 2019-DEF and 2019-XYZ.

I want a custom field called "Release Date" to be mandatory when some selects fix verson as "2019-XYZ". 

Can someone help me with this using Script Runner?

2 answers

1 accepted

1 vote
Answer accepted
Ravi Sagar _Sparxsys_
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.
October 15, 2019

Hi @Sunil Mandalika 

Here is the code for you.

def fixVersion = getFieldById(getFieldChanged()).getValue()
def releaseDate = getFieldByName("Release Date")
log.debug("Fix Version: " + fixVersion)

if (fixVersion.toString().contains("2019-XYZ") ) {

releaseDate.setRequired(true)

} else {

releaseDate.setRequired(false)
}

Use this code in the behaviour. Create a behaviour, define mapping to a project, add the Fix Version/s field and use the above code in the server-side script.

I hope it helps.

Ravi

Prashant Karakanagoudar November 12, 2019

Thanks, this worked for me.

Like Ravi Sagar _Sparxsys_ likes this
Ravi Sagar _Sparxsys_
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.
November 12, 2019

That's great. Thanks for letting me know.

Sunil Mandalika November 18, 2019

@Ravi Sagar _Sparxsys_ Sorry for the delay in responding to your answer. The script worked for us. Thank you for that. To take this a step further, can we write a regular expression in stead of checking for a constant called "2019-XYZ".

My fix version are named as "YEAR-MMM-OFFSCHEDULE", the year and month change for every month, but the last phrase does not change and it always alphabets. 

I would like to change "

if (fixVersion.toString().contains
("this to be a regular expression which validates XXXX-XXX-OFFSCHEDULE"")

the first 4 XXXX are numbers

the second 3 XXX are alphabets

Ayushi Saxena February 18, 2021

Thanks @Ravi Sagar _Sparxsys_ : It Helped me achieve similar requirement for Affect's Version.

Like Ravi Sagar _Sparxsys_ likes this
Ravi Sagar _Sparxsys_
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.
February 18, 2021

Great

0 votes
Avinash Bhagawati _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 15, 2019

Hi @Sunil Mandalika ,

With the help of Behaviours From ScriptRunner for Jira you will be able to configure this.

Thanks,

Avinash

Suggest an answer

Log in or Sign up to answer