web-resource contexts

how to include javascript on create and transition screens only ? because from javascript i am making rest call and loading javascrip as webresource and context as atl.general, due to this javascript will loading in all pages. so i want to restrict javascript load in specific screens.

javascript should be load on create, edit and transition screens only for this,

what contexts need to use??

6 answers

1 accepted

This widget could not be displayed.
The following is working for me
var transition=$("#issue-workflow-transition-submit").val();
  var editScreen=document.getElementById('edit-issue-submit');
  var issueType = AJS.$("#type-val").text();
  var issueTypeValue=$.trim(issueType);	
  if((transition=='Update by CCB'||editScreen!=null) && issueTypeValue == 'Defect'){		

//code here ..
}

Hi @Rambanam Prasad, 
I have to add add some javascript to workflow transitions as well,

Where do I have to put this code in the plugin? in atlassian-plugin.xml?  

Using webresource module we can add javascript, check the following doc for more information 

https://developer.atlassian.com/confdev/confluence-plugin-guide/writing-confluence-plugins/including-javascript-and-css-resources

if above link does't help then let me know!

Hi, 
Using the above link I added javascript that runs on atl.general pages.
But I need the JS to run on transition screens,
You have given some solution:

var transition=$("#issue-workflow-transition-submit").val();
  var editScreen=document.getElementById('edit-issue-submit');
  var issueType = AJS.$("#type-val").text();
  var issueTypeValue=$.trim(issueType);
  if((transition=='Update by CCB'||editScreen!=null) && issueTypeValue == 'Defect'){       
 
//code here ..
}

 
Where am I supposed to add this and how? Could you please tell me I would appreciate that very much.

I want my JS to run on all the issue transition windows for the permissible groups and for all the issue types.  

This widget could not be displayed.
Mizan Community Champion May 07, 2012

You can let the context be atl.general and let your script decide when to execute

for example something similar to the below code :

if((AJS.$("#issue-create")||(AJS.$("#issue-edit")){

//your script

}

i am getting "Undefined" message,

i used following code

if(document.getElementById('edit-issue-submit') !=null || document.getElementById('issue-workflow-transition-submit') !=null || document.getElementById('create-issue-submit') !=null || document.getElementById('issue-create-submit') !=null){

//my JavaScript here
}

This widget could not be displayed.
Mizan Community Champion May 06, 2012

for create issue screen the context should be "jira.issue.create" This is available in 4.4 onwards

This widget could not be displayed.

yes i seen this, but javascript should work on transition screens also :(

for you reference context for create screen is "jira.create.issue" not "jira.issue.create"(it won't work , tested on 5.0.3)

This widget could not be displayed.
Mizan Community Champion May 07, 2012

Does your js takes values from the document ? for example document.getElementById("pid") ?

bcoz pid is not available on transition screens . Even i had faced a similar problem, the js was not working on transition screen because i was trying to get pid

This widget could not be displayed.

yes ur correct, but i am testing by giving just alerts

in transtion screens we can get issueid insted of pid

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Thursday in United States

Local Atlassian Research Workshop opportunity on Sep. 28th

We're looking for participants for another workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sh...

53 views 0 0
View post

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you