Validator check on Create transition that assignee should not be empty.

Mohit Dhir November 18, 2019

Hi,

 

I wanted to make the assignee mandatory for one of the project-issuetype. I have thought on the below.

 

  • I can not change the global settings as this is only for 1 project-issuetype.
  • We can not make the assignee field mandatory in the field configuration. ( not allowed in Jira).
  • I have script runner and tried the simple scripted Validator but it does not seems to work 

          if ( issue.assignee.name == null )
          {
              return false
          }

         Tried the below as well. 

         if (issue.getAssignee() == null)
         {
              return false
         }

 

I got to understand that many thing come sinto the effect once the issue is created however validators are to check before the issue is created. 

 

Could anyone suggest a method using which I can access the create form elements and validate it.

2 answers

1 accepted

0 votes
Answer accepted
Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 19, 2019

Hi @Mohit Dhir ,

Your method is correct, please try this script : 

import com.opensymphony.workflow.InvalidInputException

if (!issue.getAssignee()){
invalidInputException = new InvalidInputException("Assignee cannot be empty.")
throw invalidInputException
}

Antoine

Mohit Dhir November 20, 2019

Hi @Antoine Berry 

Thanks for your help. Now I understand that it needs to be an exception to terminate. 

it worked thanks. 

Like Antoine Berry likes this
0 votes
Mohit Dhir November 18, 2019

Tried the below as well. Same no effect

if (issue.getAssignee() == null)
{
return false
}

Suggest an answer

Log in or Sign up to answer