Snippets

Adaptavist ScriptRunner Jira Server Custom Validator Multi Line Error Example

Created by Kristian Walker last modified
/*
* This example custom script validator script shows how you can define a multi line error message.
* "All right, title and interest in this code snippet shall remain the exclusive intellectual property of Adaptavist Group Ltd and its affiliates. Customers with a valid ScriptRunner
* license shall be granted a  non-exclusive, non-transferable, freely revocable right to use this code snippet only within their own instance of Atlassian products. This licensing notice cannot be removed or
* amended and must be included in any circumstances where the code snippet is shared by You or a third party."
*/


import com.opensymphony.workflow.InvalidInputException

// Create a map to store all errors in
Map<String,String> errors = [:]

// add in each error specifying its inxed in the map as the first paramater
// and the error message as the second paramater
errors.put("1", "Error line 1")
errors.put("2", "Error line 2")

// return the errors map which now contains the multiline error message
// Note this will return each line as a bullet point in the error message and the bullet points cannot be removed as these are added in by Jira itself and not by ScriptRunner. 
throw new InvalidInputException(errors)

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.