I am using Scriptrunner and I would like to throw an exception because the issue has no components as shown below:
How can I do that?
I am using the following code and I am checking if the components are empty but the error is not thrown. How can I fix this?
package SuperFeature
import com.opensymphony.workflow.WorkflowException
def components = issue.components
log.warn("MOUNA COMPONENTS "+components)
if(components.empty) {
log.warn("MOUNA EMPTY")
throw new WorkflowException("Issue does not have components")
}
Hi All,
even if Nic assumes that this is running in a validator, I recommend thinking about adding your business logic to a validator instead of a post function, this way you have a better control and can better communicate with the end user. I just evaluated this issue for myself and for me this is the better option.
BR
HEIKO
Try simply
if (issue.components.empty) {
throw new InvalidInputException("You must enter at least one component.")
}
I am assuming this is being run as a validator, and you are on a recent-ish version of Scriptrunner (v 7.11 or above)
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.