Wiki

Clone wiki

runner / Validators

#Custom Workflow Functions Customise and extend your workflows using complex scripts to support or enforce your business processes. ##Binding For each type of workflow function, the plugin will provide the current $issue, $currentUser, $transientVars, $args, $propertySet, $log, $originalIssue and $errors which is a Map in java and hash array in PHP, and adding strings to $errors will indicate that validation fails.

##Validators check that any input to the transition (for example, by a user) is valid, before the transition is performed.

###Examples * GROOVY

A validator to require a description.

$description = $issue.description;
if (!$description) {
    $errors[""] = "Description is required";
    $errors["description"] = "Description is required";
}

Require Fix Version if resolution is Fixed

import com.opensymphony.workflow.InvalidInputException

if ($issue.resolutionObject.name == "Fixed" && ! $issue.fixVersions) {
    throw new InvalidInputException("fixVersions",
        "Fix Version/s is required when specifying Resolution of 'Fixed'")
}
  • PHP

A validator to require a comment.

$comment = $transientVars["comment"];
if (!$comment) {
    $errors[""] = "Comment is required";
    $errors["comment"] = "Comment is required";
}

Updated