How to script a validator checking the Field input

Kateryna Lysova December 24, 2019

Hi All,

 

We have a Server version of JIRA and JIRA Service Desk. We need to write a validator for a Field to check it's input - there should be comma-separated email-addresses. We have recently installed ScriptRunner. Is this the only tool for input validating?

1 answer

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 25, 2019

There are other apps that provide validators, but because ScriptRunner lets you write code that hooks directly into the Jira API, none are quite as powerful as it is.

import com.opensymphony.workflow.InvalidInputException

def cf = ComponentAccessor.customFieldManager.getCustomFieldObjects(linkedIssues.first().destinationObject).findByName(<field name>)

if (issue.getCustomFieldValue(cf) <your rule>

{ throw new InvalidInputException("customField", "The content of <field name> is not a comma-separated set of valid emails") }

Suggest an answer

Log in or Sign up to answer