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)
}
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.