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")
}
}
Whatever it is that you're coding with that API is incorrect and it cannot do anything that you are describing.
For dynamic forms there are Behaviours:
# https://docs.adaptavist.com/sr4js/latest/features/behaviours
And these use a very different code syntax to read/update the forms.
Also several good examples could be found here: https://library.adaptavist.com/search?library-content%5BrefinementList%5D%5Bplatforms%5D%5B0%5D=dataCenter&library-content%5BrefinementList%5D%5Bfeature_names%5D%5B0%5D=behaviours
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.