Hi Team,
I having two custom fields Criteria and Reason for change. In edit issue when Criteria value changes user needs to be specify the reason as mandatory why they are changing the Criteria. For this can anyone help me to write a groovy script. I tried with the following code but it's not working.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def criteriaField = customFieldManager.getCustomFieldObjects(issue).find { it.name == "Criteria" }
def reasonForChangeField = customFieldManager.getCustomFieldObjects(issue).find { it.name == "Reason for Change" }
def criteriaOldValue = issue.getOriginalValue(criteriaField)
def criteriaNewValue = issue.getCustomFieldValue(criteriaField)
if (criteriaOldValue != criteriaNewValue) {
// Criteria value changed, make Reason for Change mandatory
if (!issue.getCustomFieldValue(reasonForChangeField)) {
issue.setCustomFieldValue(reasonForChangeField, "Default value or handle as needed")
}
}