2.2 Video: Modifying Existing Scripts in ScriptRunner for Jira Data Center/Server



The scripts in the video above can be simplified with HAPI. For example, using HAPI, the script to search for select issues and replace the custom field value is as follows:

groovy
Issues.search("project = GAV AND issuetype = 'Tour Build D' AND 'VT Type D' = 'Deep Sea'").each { issue -> issue.update { setCustomFieldValue('VT Type D') { replace('Deep Sea', 'Special') } } log.warn(issue.key) }

See the HAPI documentation for more information on searching for issues and updating fields