In ScriptRunner v5.3, I added some custom javascript via a script fragment. The js added an event listener to when a particular (custom) canned script was loaded, so that I could wire up change listener to a project select drop-down (which only existed on the DOM after the canned script was loaded). This other listener used a REST call to load issues for the selected project that fit a JQL query. The code is as follows:
!(function ($) {
"use strict";
$(function () {
var scriptName = "com.onresolve.scriptrunner.canned.jira.admin.ReconcileGbhTime";
$(document).on("/start/" + scriptName, scriptLoad);
function scriptLoad() {
var projectSelect = $("select#project");
var issueSelect = $("select#issue");
function getIssuesForProject() {
var params = {
jql: "project = '" + projectSelect.val() + "' AND statusCategory = 'In Progress' "
+ "AND issuetype in standardIssueTypes() and issuetype != Deliverable",
fields: "summary",
maxResults: -1 //absolute max is 1000
};
$.getJSON("/rest/api/2/search", params, function(res) {
issueSelect.empty();
issueSelect.append(new Option("", ""));
for(let issue of res.issues) {
issueSelect.append(new Option(issue.key + ": " + issue.fields.summary, issue.key));
}
issueSelect.change();
});
}
projectSelect.change(getIssuesForProject);
getIssuesForProject();
}
});
})(AJS.$);
In ScriptRunner v5.4, it appears the admin section has been changed quite a bit, and no “/start/<script-name>” event is getting fired when I select a built-in script. Therefore, the project drop-down has no change listener and the issue drop-down is never populated.
What event can I listen to, other how can I otherwise add an event to the drop-down that is created as part of this canned script?
p.s. I already figure out that the JQuery selector for the drop downs needs to be replaced with something like:
$("label[for='project']").siblings("select");
Hi,
I have a similar issue on my side, but instead of using Web Fragment to include JavaScript, I was adding a script tag in the description of a built-in script. This script was executed with version 7.5.3 of JIRA and SR 5.2.1, but it is not executed anymore with SR version 5.4.49.
alert("load");
JIRA.HideBuiltIns = JIRA.HideBuiltIns || (function() {
return {
init: function() {
alert("do something");
}
};
})();
AJS.$(document).ready(function() {
alert("onready");
setTimeout(JIRA.HideBuiltIns.init, 10);
// Button Back to List also needs to hide built-ins
AJS.$("#cancel").click(function() {
alert("oncancel");
JIRA.HideBuiltIns.init();
})
});
Thanks
Can we customise eazyBi report using JavaScript in Jira Script Runner ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.