Script fields return type checking

Static type checking has been enhanced to include checking that the returned value is correct for the configured index, if any.

This is best illustrated with an example:

return type

Here, we have a field configured that will show the maximum of the subtasks' remaining estimate. (If all subtasks were worked on in parallel, the maximum remaining estimates of the subtasks is the shortest time they could all be completed in).

We have configured the Duration Searcher, which expects a java.lang.Long. However, if it’s already a subtask, we return a String: "none". This is a mistake, we should return null.

Whilst you should still use the preview functionality it would not have caught this error, as it will only become apparent if the script field is on a subtask.

However, you should still use the preview functionality with a range of different issues (eg some standard issue types, some subtasks), which will help find runtime errors.

Bug fixes

Have questions? Visit the Atlassian Community to connect, share, and learn with other Atlassian users and experts, including Adaptavist staff.

Ask a question about ScriptRunner for JIRA, Bitbucket Server, or Confluence.

Want to learn more? Check out courses on Adaptavist Learn, an online platform to onboard and train new users for Atlassian solutions.