2.1 Video: Groovy Basics for ScriptRunner Data Center/Server

For more information on scripting, check out the HAPI documentation and our Best Practices section.



The script in the video above can be simplified with HAPI. For example, using HAPI, the script to return the value of a custom field in an issue is as follows:

groovy
def issue = Issues.getByKey('GAV-15') issue.getCustomFieldValue('Reason for QA Fail') def value = issue.getCustomFieldValue('Reason for QA Fail') if (value) { return value } else { return "There is no value in this field on the chosen issue" }

See the HAPI documentation for more information on reading custom fields