Hi, I am trying to create a transition validator that allows a transition only if there is a non-blank field in the parent issue.
From my testing this doesn't seem achievable using the standard JIRA validators, so I'm looking at Script Runner to achieve this.
I can certainly get it going with a Condition on the workflow based on a JQL query:
issuetype = Development AND status = Testing AND issueFunction in subtasksOf ("'Release Note' IS NOT EMPTY AND issuetype in (Feature,Bug)")
The problem with this is that is removes the transition button, whereas I would prefer to display an error. JQL is not available in Script Runner validators, so I'd appeciate any pointers on
Here is a complete solution for you. We have this running for a few of our workflows.
import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.issue.fields.CustomField import com.opensymphony.workflow.InvalidInputException String customFieldName = "custom field name" String errorToShow = "No You can't" boolean result = false; MutableIssue muIssue = issue; MutableIssue parentIssue = muIssue.getParentObject() as MutableIssue CustomFieldManager cfManager = ComponentManager.getInstance().getCustomFieldManager() CustomField cf = cfManager.getCustomFieldObjectByName(customFieldName) parentCustomFieldValue = parentIssue.getCustomFieldValue(cf).toString() log.warn(parentCustomFieldValue) if (parentCustomFieldValue != "" && parentCustomFieldValue != "null") result = true if (!result) invalidInputException = new InvalidInputException(errorToShow)
You can save this into any .groovy file
Then in your workflow validator add a script and put the path where you put the file with the filename.
edit the 2 line right after the imports to show your error and the custom field name you want to look at.
It currently set to look if it's empty.
Another method is with the Fields Required validator. This comes with the JIRA Suite Utilities add-on. It lets you pick multiple fields, including all custom fields in your JIRA instance.
Here is the error presented when trying to transition past this validation. You can see below Assignee is a core JIRA field but "RS - Capital Labor" is a custom field in my instance.
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG