Forums

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

How to script a validator checking the Field input

Kateryna Lysova
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
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-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
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