Currently, I'm trying to define two conditions regarding the component field in a subtask:
- the field should be required --> I realized this requirement setting the specific option in the corresponding field configuration. Everything fine.
- the field should only contain one component, not more and not less than one...
I tried to define a behaviour with respect to the specific project and field. I was successfull in checking the amount of components in the specific subtask and to send a user message or an invalid input message.
Now my question: When I'm entering two components in the edit dialogue the behaviour fires, but jira updates the issue (what I wanted to avoid) although the behaviour throws the exception.
Here is the snapshot of my behaviour code:
def issueManager = ComponentAccessor.getIssueManager()
def issue = issueManager.getIssueObject("ITP-25")
def NumberComponents = issue.getComponents().size()
log.debug "NumberComponents: " +NumberComponents
if (NumberComponents != 1){
throw new InvalidInputException("component", "Only one component is allowed")
return null
}
I tried some alternatives, e.g. "return false" or throwing the invalidInputException without the assignment to the field...but nothing helps. Thus, I assume I'm not on the right track...
Has someone an idea? Thanks a lot in advance!