Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

AJS ERROR "Uncaught ReferenceError: AJS is not defined" in customer portal page JSD

Vikash Kumar
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.
April 7, 2014

I am facing AJS ERROR "Uncaught ReferenceError: AJS is not defined" in customer portal page of JIRA SERVICE DESK.

Please find error below.

  • Uncaught ReferenceError: AJS is not defined -----------> confirmClosure.js:1
  • AJS.contextPath() is not here. Please use require("servicedesk/util/context-path") -----------> aui.js:18
  • event.returnValue is deprecated. Please use the standard event.preventDefault() instead.-----------> aui-dependencies.js:6

I have used this dependency com.atlassian.auiplugin:ajs It works for a simple java script alert but not for AJS.

Any help on this is highly appreciated. Thanks in Advance.

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Vikash Kumar
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.
April 28, 2014

I have changed Jira version to 6.1 and amps.version to 4.2.13 temporarily and it solved the problems.

0 votes
Vikash Kumar
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.
May 19, 2015

Hi @Boris

Thanks for your quick reply.

jira.version is: 6.2.2

amps.version is: 4.2.20

0 votes
EddieW
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.
May 12, 2015

Uninstalling and reinstalling every version under the sun didn't help. I suspect JSD uses asynchronous loading of resources.

 

As a workaround I setup an anonymous function to check for the AJS call i need to succeed before going to work, an that function is on a recursive timeout to keep checking until it exists.

 

Also AJS.contextPath yells with an error in JSD pointing to a utility, so I use that instead, but you can check whatever JS/AJS call you need to be present.

 

// this must be a named function to be able to call itself
 
function onFunctionAvailable(testCondition) {
    if (testCondition() === true) {
        console.log("AJS Methods Ready");
		// test passed, methods are ready, do work
        callbackMethodWhenStuffIsPresent(AJS.$);
    } else {
		// methods not yet present/ready, check back in 50ms
        console.log("AJS Methods not ready");
        setTimeout(function () {
        onFunctionAvailable(testCondition);
        }, 50);
    }
}
 
//this calls the method above, but uses anonymous function to prevent immediate error when argument is evaluated.
// replace 'require("servicedesk/util/context-path")' with whatever method/call you need to be present
onFunctionAvailable(function (){try{return typeof(require("servicedesk/util/context-path")) === 'string';}catch(err){return false;}});
0 votes
Boris Georgiev _Appfire_
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.
April 8, 2014

Which version of JIRA are you using ?

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events