You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi,
I'm new in scriptrunner and i need help to create a behaviour to set a field mandatory if priority is "high". But the script does not work.
import com.atlassian.jira.issue.priority.Priority
def priority = getFieldById("priority")
def justificacion = getFieldById("customfieldid_15801")
if (priority == "High") {
justificacion.setRequired(true)
}
else {
justificacion.setRequired(false)
}
Thansk!
Maybe something like this but whit priority
import com.atlassian.jira.issue.resolution.Resolution
def resolutionField = getFieldById("resolution")
def fixVersionsField = getFieldById("fixVersions")
def resolution = resolutionField.getValue() as Resolution
if (resolution.name == "Fixed") {
fixVersionsField.setRequired(true) fixVersionsField.setHidden(false) }
else {
fixVersionsField.setRequired(false) fixVersionsField.setHidden(true)
}
You'll need to get the Priority field value for the if-else condition. For example:
import com.atlassian.jira.issue.priority.Priority
import com.atlassian.jira.issue.IssueConstantImpl
def priority = getFieldById(getFieldChanged())
def selectedPriority = ((IssueConstantImpl) priority.getValue()).getName()
def justificacion = getFieldById("customfieldid_15801")
if (selectedPriority == "High") {
justificacion.setRequired(true)
}else {
justificacion.setRequired(false)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.