AJS script failing after upgrade to JIRA 9.4

Kara Craig November 16, 2023

We're testing an upgrade to v9.4 from v8.19, and the custom scripts we have for ScriptRunner scripted fields are no longer rendering on the issue view page. 

Our scripts output AJS code to update, for example, the ghx-issues-in-epic-table

In the upgraded JIRA product, when viewing an issue the developer tools are showing the error:  "TypeError: AJS.$ is not a function", and the table and field are not displaying as expected. 

I have read over the changes in Preparing for JIRA 9.0 documentation but it's not clear to me how this applies to our usage within the ScriptRunner Scripted Fields. 

Any help or experience with the same challenges would be much appreciated. 
Thanks.

2 answers

1 accepted

0 votes
Answer accepted
Kara Craig November 21, 2023

Thanks for the help, we found the solution we were looking for. 

Starting with the details on this Preparing for JIRA 9.0 page, and the details outlined here, we tracked down how to add the resourcePhaseCheckpoint.defer option in our script and this has resolved the issue.

ie.

String wrapInScriptTag(content)
{
    //def output = '''<script type="text/javascript">'''+content+'''</script>'''; // v8
    def output = '''<script type="text/javascript">resourcePhaseCheckpoint.defer.then(() => {'''+content+'''});</script>''';  // v9 FIX
}
0 votes
Peter-Dave Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 16, 2023

It might be helpful to consult this page: https://bitbucket.org/atlassian/platform-module-usage/wiki/aui.md

And review the AUI dependency change associated with your jira upgrade, then review the AUI changelog. E.g. https://aui.atlassian.com/aui/latest/docs/upgrades/aui-9.html#9.2-to-9.3

Also, from your old and new versions of jira, you can run "AJS.version" in your developer panel to get the specific AUI version used in each.

For example, I'm on Jira 8.20.26 and AUI version is 9.2.3-4dc984d9f

That being said, I don't think there are any changes that would cause AJS.$ to error out.

I'm early in my 9.x exploration (waiting for 9.5 LTS), and I've not encountered this (and I do use some AJS.$ functions). So perhaps a more specific/detailed example would help.

Matt Doar
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 16, 2023

It may also be worth reaching out to the support team at Adaptavist, the ScriptRunner vendor

Suggest an answer

Log in or Sign up to answer