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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Custom field retaining data when nexting through Jira issue search results

Mike Gilson
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Oct 30, 2023

A custom field that pulls custom plugin data from the jira database is retaining data from the previous jira issue when nexting to the next jira issue. This leads to improper values being displayed to the user.

This issue only occurs with the custom field when nexting through Jira issue search results.

The version of Jira Data Center being used is version 9.4

 

Below is the view.vm file for the custom field, along with the javascript file executed by the field.  id = id, issue.key = Jira Issue Key, stage = D,T,C

 

view.vm


#disable_html_escaping()
$webResourceManager.requireResource("com.custom.field:devops-revision-field-resources")
$webResourceManager.requireResource("com.atlassian.auiplugin:aui-experimental-expander")

<div id="${id}" class="devops">
<div id="${id}" class="button-spinner"></div>
</div>

<script>

// Idea for logic below came from https://javascript.info/onload-ondomcontentloaded#:~:text=we%20can%20check-,document.readyState,-and%20setup%20a
function loadRevs() {
return loadRevisionField("${id}","${issue.key}","${stage}");
}

if (document.readyState == 'loading') {
document.addEventListener('DOMContentLoaded', loadRevs);
} else {
loadRevs();
}
</script>

revisonfields.js


function loadRevisionField(fieldID,issueKey,stage){
console.log("Args: "+fieldID+":"+issueKey+":"+stage);
RevAPI.baseURL = window.location.origin;
function displayRevs(revInfo){

AJS.$('#'+fieldID+'.button-spinner').spinStop();
let domObj = AJS.$('#'+fieldID+'.devops');
for(let r in revInfo){
let rev = revInfo[r];
appendRevision(domObj, rev);

}
}
AJS.$('#'+fieldID+'.button-spinner').spin();
RevAPI.getRevisions(displayRevs,issueKey,stage)

}

function appendRevision(domObj,rev){
const maxPaths = 20;

console.log('adding revision');
console.log(rev);
let input = AJS.$('<input id="toggle-'+
rev.repo_name+'-'+rev.revision_number+
'" class="toggle devops-revs" type="checkbox">');

let label = AJS.$('<label for="toggle-'+
rev.repo_name+'-'+rev.revision_number+
'" class="devops-revs"></label>');
let revLink = AJS.$('<a href="'+rev.link+'">'+
rev.repo_name+'|'+rev.revision_number+'</a>');
label.append(revLink);


const expander = AJS.$('<div class="expand devops-revs"></div>');
let paths = AJS.$('<section></section>');
for (p in rev.paths){
let path = rev.paths[p];
let pathObj = AJS.$('<div class="rev-path"></div>')
if (path.isBuilt){
pathObj.append('<span class="circle green"></span>')
} else {
pathObj.append('<span class="circle red"></span>')
}
pathObj.append('<span class="path">'+path.path+'</span>')
paths.append(pathObj)
if(p==maxPaths){
let leftOver = rev.paths.length - maxPaths;
if(leftOver>0){
let more = AJS.$('<div class="rev-path"></div>');
more.append(leftOver+' more things on this revision');
paths.append(more);
}
break;
}
}

expander.append(paths);
domObj.append(input).append(label).append(expander);




}


var RevAPI={
baseURL: null,

getRevisions: function(callback, issueKey, stage){
const url = RevAPI.baseURL+'/rest/devops/1.0/rev/issue/'+issueKey+'/'+stage;
AJS.$.get(url,[],function(resp){
callback(resp);
});
}
}

0 answers

Suggest an answer

Log in or Sign up to answer