Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Make Jira Comment Field mandatory when the priority field is updated

QueenMary Bastin October 2, 2021

Here I have a requirement to make the Comment field mandatory when the priority is updated.

I tried the below code using behavior but it makes the comment field field mandatory when the priority is changed.

Along with this it is making comment mandatory in all the transitions of my workflow.

For example when I move the ticket to verify state we have a screen which will pop up to fill some needed values there also the comment fields has been made mandatory because of my behavior script.

If I disable the code it works fine. Here is the code which I used. 

import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import org.apache.log4j.Level
import org.apache.log4j.Logger

@BaseScript FieldBehaviours fieldBehaviours

def log = Logger.getLogger("sr4j.behaviour.com")
log.setLevel(Level.DEBUG)

def commentField = getFieldById("comment")
def priority = getFieldById(getFieldChanged())
def priorityValue = priority.value

if(priorityValue != underlyingIssue?.priority.getName())
{
log.debug("Required True")
commentField.setRequired(true)
}
else
{
log.debug("Required False")
commentField.setRequired(false)
}

 

can anyone please help me in resolving this issue

0 answers

Suggest an answer

Log in or Sign up to answer