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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Get issue key of link 'is Feature of Epic' using announcement banner (javascript)

Hello,

 

I would like to add fixversion of all links type 'is Feature of Epic'.

I wrote the script for adding the fixversion for 'issues in Epic' links.

How can I get the issue key of the 'is Feature of Epic' links using announcement banner?

I tried this code (without success):

<script type="text/javascript">
jQuery(document).ready(function($) {
setInterval(function (){
var editdl = AJS.$('.links-list')
var proj = AJS.$("#project-name-val").text();
var project = proj.trim();
if(project == 'WLA WorkBacklog' || project == 'WLA Solution Intent'){
var title = document.getElementsByTagName("DT");
for(var i=0; i<editdl.length; i++){
if(title[i].innerHTML == 'is Feature of Epic'){
var div = document.getElementsByClassName("links-list");
var nodelist = div[i].getElementsByTagName("DD").length;
for(var j=0; j<nodelist; j++){
var issueKey = div[i].getElementsByTagName("dd")[j].getElementsByClassName("issue-link link-title").value
AJS.$.getJSON(AJS.contextPath() + '/rest/api/latest/issue/' + issueKey, function(data){
var value = data.fields.fixVersions.map(function(version){return version.name});
var actions = AJS.$(row).find('td.issue_actions');
AJS.$(actions).before('<td class="nav">' + value + '</td>');
});
}

}
}
}},500);
});
</script>

 

What am I doing wrong?

Thanks ,

Daniel

1 answer

0 votes

I'm not going to ask why you are doing this or why you tagged your post with scriptrunner or adaptavist ... but let's see what we can find out is going on with this script.

The first thing that seems odd to me is this:

var actions = AJS.$(row).find('td.issue_actions');

"row" is not defined anywhere. 

And in modern versions of jira, I don't see any td element with issue_actions class as specified by find('td.issue_actions').

My guess is that you want to somehow display the fixVersion of your liked issue in some way next to the status and priority. Those are not in a table or td (at least not in my jira 8.11).

My suggestion would be to try to add it after the link-summary

Try something like this (also leveraging some jquery to remove some of the for loops)

<script type="text/javascript">
AJS.$(document).ready(function() {
setInterval(function () {
var project = AJS.$("#project-name-val").text().trim();
if (project == 'WLA WorkBacklog' || project == 'WLA Solution Intent') {
AJS.$('dl.links-list dt[title="is Feature of Epic"]').next('dd').find('.issue-link.link-title').each(function(){
var link = AJS.$(this);
var url = AJS.contextPath() + '/rest/api/latest/issue/' + link.text() + '?fields=fixVersions';
AJS.$.getJSON(url, function(data){
var versionName = data.fields.fixVersions.map(function(version){return version.name});
link.closest('p').after('<p style="text-align:right;">'+versionName+'</p>');
});
});
}
}, 500);
});
</script>

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you