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
Thanks!
HI Adam,
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.
and voilà
have fun
Just perfect! Thanks so much for your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Adam,
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.
Cheers,
Brannon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline 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.