web resource js not invoked in scriptrunner web item

Amro Hassaan
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.
June 10, 2016

I am following the tutorial here to proof the concept to proceed with using this feature in building some functionality. So far the dialog is working fine but the javascript is not invoked.

  1. added the js file a directory that is specified in the JVM required args in setenv.sh
  2. off course installed the web resource in scriptrunner
  3. created the web item dialog as per the example in the tutorial

the dialog shows once the web item is clicked but the javascript in the web resource is not taking effect. 

Debugging it in the browser javascript debugger i don't see it called at all.

What could be missing? do i need to reference the js file explicitly in the html of the dialog?

 

Thank you




 

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
JamieA
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.
June 10, 2016

I notice in the example html, the dialog id is sr-dialog, whereas in the javascript the id is my-own-dialog. Whatever you use here, these need to be the same. Bit of a docn bug.

Also, if you want to edit the js and have it refreshed automatically, you need to run with atlassian.dev.mode=true, which means not in production. 

Amro Hassaan
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.
June 10, 2016

Yes..that is the case. I have dialog id matching in the .js and the html returned from the REST. I also have the atlassian.dev.mode=true in the JVM REQ ARG. Also restarted JIRA multiple time, cleared the caches, hard edited the web item and the web resource from the GUI in SR and still don't see the JS. I copied it, pasted in the console in chrome and it excutes perfectly once the dialog shows so the problem seems to be that web item is not linked to the web-resource somehow. 

Note worthy, I have created a directory called 'resources' under the 'scripts' dir of SR and added that to the -Dplugin.resource.directories. Could that be the problem?irs.resource.directories

JamieA
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.
June 10, 2016

shd be ok, but the js path should be relative to the "resources" directory then. Check your server logs, it should say if it can't find the file.

Amro Hassaan
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.
June 10, 2016

yes..it is relative to "resources", the List of resources panel complains actually if i try a wrong path and warns me. All that and still not working and to my bafflement nothing shows in the logs regarding this at all!!! I tried erasing all web items and resources and started over and restarted JIRA and cleared cache and nothing works...

Amro Hassaan
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.
June 11, 2016

Looking at the page source, I am seeing the resource js file being downloaded and available among other resources. Just not sure why it doesn't execute whereas it executes only when i paste in the console. Could it be a latency issue or something? very confusing.

Amro Hassaan
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.
June 11, 2016

Jamie Echlin, after lots of debugging I am noticing that the resrouce js file i have created ('test.js') is available among other js resources under the 'Resources' tab in Chrome debugger (F12), while it doesn't show at all under the 'Debug' tab in Firefox...despite all other resources supplied by "com.onresolve.jira.groovy.groovyrunner"  are available and all show in the source of the pages in both cases...but in reality it is not available among the resource captured by the browser! Any help here would be extremely appreciated. Thank you

JamieA
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.
June 13, 2016

Contact us at https://productsupport.adaptavist.com/servicedesk/customer/portal/2 and we can arrange a screen sharing session, I think we've got as far as we're going to get on this forum.

Amro Hassaan
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.
June 13, 2016

Jamie Echlin Thank you so much for the great support and help. Here is the REF#: SRJSUP-507 

 

Christian Schlaefcke
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.
March 28, 2019

Hi,

I know that I am late but I am also running in this kind of problem.

Would it be possible to make SRJSUP-507 public or could someone post the solution here?

Best Regards,

Christian

Like # people like this
TAGS
AUG Leaders

Atlassian Community Events