We need to get the issue type from edit screen through Javascript. How can get this details? Is there any function there similar to getting the issue id or issue key like the below?
JIRA.Issue.getIssueId()
JIRA.Issue.getIssueKey()
I don't think there is a method for issue type specifically (I don't see one either browsing a bit through the js methods). Alternative could be workaround from https://community.atlassian.com/t5/Jira-Software-questions/How-to-get-the-Summary-of-the-Issue-Using-JQuery-or-JavaScript/qaq-p/601115 which if modified seems to work:
function getIssueType() {
var key = this.JIRA.Issue.getIssueKey();
var issueType;
AJS.$.ajax({
url: "/rest/api/2/issue/" + key,
type: 'get',
dataType: 'json',
async: false,
success: function(data) {
issueType = data.fields.issuetype.name;
}
});
return issueType;
};
getIssueType();
Not perfect but does the job if nothing else works.
You probably could just use something like `document.querySelector("path to issuetype element")` and then get the issuetype from that as well.
E.g.
document.querySelector("#type-val").innerText;
// ' Task'
document.querySelector("#type-val").innerText.trim();
// 'Task'
I would say using the getter is better to avoid spamming additional ajax calls to Jira, with trim this should work fine to remove the whitespace.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.