Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,366,187
Community Members
 
Community Events
168
Community Groups

Scriptrunner behaviour - set field mandatory if specifics values selected in priority system field

Edited

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)

}

 

1 answer

1 accepted

1 vote
Answer accepted

Hi @Celeste D_Alessandro ,

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)
}

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events