I have two custom fields on my stories that I need to add some validation on. If the first custom fields value is "Yes" then the second custom field value must also be set to "Accepted" in order for a JIRA transition to be able to take place.
I have tried the two following approaches, both without much luck:
Approach 1:
import com.atlassian.jira.component.ComponentAccessor;
def pciChange = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("PCI Affecting Change?");
def cabApproval = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("CAB Approval");
def pciValue = (String)issue.getCustomFieldValue(pciChange);
def cabValue = (String)issue.getCustomFieldValue(cabApproval);
if (pciValue == 'Yes') {
if (cabValue != 'Accepted') {
return false
}
}
I have tried adding in error logging in this to try and find out the value of my variables during the process but nothing is being logged which would lead me to believe that my custom fields are not being found.
This approach resulted in the validation rule always being applied no matter what the value of "pciValue".
Approach 2:
cfValues["PCI Affecting Change?"]?.value != "Yes" || cfValues["CAB Approval"] != "Accepted"
This approach resulted in seemingly no validation being applied at all.
Any advice or links to documentation that would help solve this would be much appreciated!