Requirement:
Custom Field has three values:
When Custom Field value = A, require at least 1 ticket from Project ABC to be linked in the Linked Issue field
When Custom Field value = B, require at least 1 ticket from Project EFG to be linked in the Linked Issue field
When Custom Field value = C, require at least 1 ticket from Project ABC AND EFG to be linked in the Linked Issue field
Can anyone provide any insight on this? Thank you
Here's one approach. You can create a validator of type Simple Scripted Validator [ScriptRunner] and create a script like below. I haven't tested it, so it may need a bit of tweaking, but it should be mostly what you need and get you headed in the right direction. Then just give it a meaningful error message for when the script returns a value of false.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
CustomField myField = customFieldManager.getCustomFieldObjectByName("My Field")
String myFieldValue = issue.getCustomFieldValue(myField)
def linkFound = false;
def links = issue.getOutwardIssueLinks();
links.each {
if (myFieldValue.equals("A") && it.getDestinationObject().getProjectObject().getName().equalsIgnoreCase("ABC")) {
linkFound = true;
}
if (myFieldValue.equals("B") && it.getDestinationObject().getProjectObject().getName().equalsIgnoreCase("EFG")) {
linkFound = true;
}
if (myFieldValue.equals("C") && it.getDestinationObject().getProjectObject().getName().equalsIgnoreCase("ABC AND EFG")) {
linkFound = true;
}
}
return linkFound;
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.