I am looking to create “calculated measure” for below JQL filters:
This JQL list issues that have only “Is blocked by” linkage
project = “ABC” AND issueFunction in hasLinks(“is blocked by”) AND issueFunction not in hasLinks(blocks) AND resolution = Unresolved This JQL will only list issues that have “Blocks” linkage
project = “ABC” AND issueFunction in hasLinks(Blocks) AND issueFunction not in hasLinks(“is blocked by”) AND resolution = Unresolved This JQL will only list issues where there is no issue linkage
project = “ABC” AND issueFunction not in hasLinks() AND resolution = Unresolved
Goal is to create a pie chart showing a spread of issues by:
The fastest way for the report to return results for this would be to define a new custom field in the Advanced settings and use custom JavaScript code to iterate through issue links and check if each issue is blocked/is blocking other issues.
You can use the following code in the Advanced settings:
[jira.customfield_blocklinks]
name = "Blocker links"
data_type = "string"
dimension = true
javascript_code = '''
var blocks = false;
var isBlockedBy = false;
if (issue.fields.issuelinks.length>0) {
var links = issue.fields.issuelinks;
for (var i = 0; i < links.length; i++) {
var link = links[i];
if (!isBlockedBy && link.inwardIssue) {
if (link.type.inward == "is blocked by") {
isBlockedBy = true;
}
} else if (!blocks && link.outwardIssue) {
if (link.type.outward == "Blocks") {
blocks = true;
}
}
if (isBlockedBy && blocks) {
break;
}
}
if (!isBlockedBy) {
if (!blocks) {
issue.fields.customfield_blocklinks = "No Blockers";
} else {
issue.fields.customfield_blocklinks = "Blocks";
}
} else {
if (!blocks) {
issue.fields.customfield_blocklinks = "Is Blocked";
} else {
issue.fields.customfield_blocklinks = "Blocks and Is Blocked";
}
}
}
'''
I used the “is blocked by” and “Blocks” link names in this JavaScript code. Please check that the link names in your Jira are the same (with the same letter casing). If not, change them accordingly.
Save the Advanced settings, then go to the “Source Data” tab and click “Edit” for your Jira source. There, in the “Custom fields” section you can select this “Blocker links” custom field to be imported and trigger the import.
Once the import finishes, you can use this dimension in your reports to filter the issues. You can also add the Issue (or Project) and Resolution dimensions to the Pages section to filter by the necessary project and to only show the unresolved issues:
Thank you so much your proposed solution worked!!! One exception, after creation of the “calculated custom field” I only see two option in the filter “Is Blocked” and “No Blockers”, I don’t see “Blocks” as I see in your demo account, what could be the issue?
The link names are case-sensitive. Could you please check that in your Jira, the outward link is named exactly “Blocks”?
There have been cases where “blocks” or even "blocks " (with a space at the end) have been used in Jira issue links.
The other thing you can check- do you have a JQL query filter set up for your report account? This filter could prevent the “Blocks” issues from being imported into this account.
When there are no “Blocks” issues imported into the account, the “Blocks” member will not be created in the “Blocker links” dimension.
Let me know if you manage to find the issue or if you need further assistance with this!
Nauris