Hi All,
I have tried using behaviour and putting my script in the Initialiser and in the server script as well for the corresponding field but the script is not working as Intended
Requirement -
Based on the "Project category" , i need to check "Issue type" and if the issue type is "BUG " then based on that I need to make a "Root Cause" mandatory while creating the issue and editing the issue as well .
At the time of create the scripts functions well but at the time of Editing the issue and changing the Issue type from BUG to other or VICE-VERSA the "Root Cause" field does not become mandatory or non mandatory on the basis of issue type?
Please find the below scripts-
I am using the same script at both the places.
NOTE - The issue what i have observed is when i ma editing the Issue type its ID is not getting changed and it still returns the initial ID of the issue type and hence the IF condition is failing.
----------------Initialiser and Server Script on the Field Issue type ----------------
import com.atlassian.jira.component.ComponentAccessor
import groovy.transform.BaseScript
import static com.atlassian.jira.issue.IssueFieldConstants.*
def field = getFieldByName("Issue Type")
def value1 =field.getValue() as String
def pdv = getFieldById("customfield_11104")
log.warn("Value while editing the issue: "+value1)
if(underlyingIssue.getProjectObject().getProjectCategory()){
if(underlyingIssue.getProjectObject().getProjectCategory().getName().toString().startsWith("NED")){
if (value1 == "10102"){
log.warn('Issue type is BUG at the time of edit')
pdv.setRequired(true)
log.warn("Root cause: ")
}
else
{
pdv.setRequired(false)
log.warn('Issue type is not the BUG at the time of edit')
}
}
else {
pdv.setRequired(false)
log.warn('Project category is not NED at the time of edit')
}
}