I have a script runner validator that stops users creating issue if there is an open issue with a custom field value selected......
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.opensymphony.workflow.InvalidInputException
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
//get user
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchProvider = ComponentAccessor.getComponent(SearchProvider)
def customFieldManager = ComponentAccessor.getCustomFieldManager()
//get the issues in project SEW of type Notification that have a value in the District council field
def JQLQuery = jqlQueryParser.parseQuery("project = SEW AND issuetype = \"Notification\" AND \"cf[10405]\" is not EMPTY")
def results = JQLQuery ? searchProvider.search(JQLQuery, user, PagerFilter.getUnlimitedFilter()) : null
def issues = results? results.issues : null
// get all the values of the District council field from the issues
def cF = customFieldManager.getCustomFieldObjectByName("District council")
def values = []
issues.each {
values.add(it.getCustomFieldValue(cF))
}
//get the issue that is trying to be created, find the value of District council they have entered, check it isnt in the values list
// if it is then throw the error
Issue issue = issue
def cFValue = issue.getCustomFieldValue(cF)
if(cFValue in values) throw new InvalidInputException("CANNOT LOG ON - SEWER ISSUE ONGOING")
I now need to know if there a way the user can override this after seeing the prompt?