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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's great. Thanks for letting me know.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Great
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Sunil Mandalika ,
With the help of Behaviours From ScriptRunner for Jira you will be able to configure this.
Thanks,
Avinash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.