Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How would you validate if Priority is set to "P0"

Hani Juha November 28, 2018

Use Case: When a bug is filed as a Priority 0 or "P0", I want to trigger a validation rule that requires the user to enter information into a field ("Why is this a P0?")

 

Is this possible?

1 answer

0 votes
Tansu Akdeniz
Community Champion
November 29, 2018

Hi @Hani Juha,

One solution is the following script if you have Script Runner add-on.

  • Go to the Bug Workflow and Edit
  • Find "Create transition"
  • Add Validator-> Script Validator -> Custom Script

Paste the code;

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.opensymphony.workflow.InvalidInputException

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField reasonFieldCF = customFieldManager.getCustomFieldObject("customfield_xxxxx");

if(issue.getPriority().getName().equals("P0")){
    if(issue.getCustomFieldValue(reasonFieldCF) == null){
            invalidInputException = new InvalidInputException("Please fill the reason field.")
    }
}

Also, you can do it via Behaviours feature. There are many examples on the web.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events