Global On-Edit Scripts
On-Edit Validator
Executed during validation phase when a user submits Issue Edit form or changes a field.
Context
Variable | Description |
---|---|
result | Result of validation; boolean value, default value is True |
invalid_fields | PyDictionary(), empty by default; should be used like this: |
description | A general message shown to the user if validation failed |
issue | current Issue object with fields modified according to the user input; may be None if previous validations failed |
parameters | a map, containing edit form field values; each value is a Java array, even if is a single value field |
updateType | Available in JssPro 3.0.2 and later. The type of the originating event. May be one of the following: |
validationResult | Available in JssPro 3.0.2 and later. com.atlassian.jira.bc.issue.IssueService.AssignValidationResult for 'assign' |
log | org.apache.log4j.Logger |
Sample On-Edit Validator Script
if "TEST" in issue.getSummary(): result = False description = "TESTs are not allowed" invalid_fields["summary"] = "Please do not specify TEST here"
If you want to compare modified issue with an original one, you may get it via IssueManager. The following script does no allow to edit Summary field:
from com.atlassian.jira.component import ComponentAccessor issue_manager = ComponentAccessor.getIssueManager() original_issue = issue_manager.getIssueObject(issue.getKey()) if issue.getSummary() != original_issue.getSummary(): result = False description = "You can not change Summary" invalid_fields["summary"] = "Please do not change me!"
On-Edit Post Function
This is executed on issue edit after a validation has succeeded, but before issue is saved. You may update issue fields here.
- This script is not executed on issue transitions
Context
Variable | Description |
---|---|
issue | current MutableIssue object |
log | org.apache.log4j.Logger |
Sample On-Edit Post Function
if issue.getProjectObject().getKey() in ["DEV"]: if not "(Development)" in issue.getSummary(): issue.setSummary(issue.getSummary() + " (Development)")
Tips and Tricks
On-edit scripts are global for a JIRA instance. This means that they are executed for any issue. If you need to distinguish issues by project, issue type, etc., you should do this manually in the script or use 'classifiers' routines shipped with JssPro:
if issue.getProjectObject().getKey() in ["PM", "DEV"]: # do something pass