Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,359,759
Community Members
 
Community Events
168
Community Groups

How can I get linked issues from a transition screen with SIL?

Preamble

I am trying to add a requirement to add an 'Is Blocked By' issue link to a ticket when performing a certain transition.

I have SIL code that does this here:

if (size(linkedIssues(key, "Blocks", -1)) == 0) {
return false, "comment", "You must add an 'is blocked by' ticket link to denote which issue is blocking this work.";
};

This basically says that if the amount of linked issues with the 'Blocks'  type is zero, don't allow the transition and give an error message.

This works fine, but unfortunately it means that a user has to add the link through the 'More' menu, then make the transition.  Or more commonly, try to transition, then go back through that.

For other similar issues, I have used the 'HasInput' method to figure out if a field in a transition screen has content.  For example, the following will validate that either Assignee or a custom field is populated in order to make a transition:

if(hasInput("assignee")) {
return true;
};
if(hasInput("customfield_10900")) {
return true;
};
if(isNotNull(assignee)) {
return true;
}
if (isNotNull(customfield_10900)) {
return true;
};
return false, "comment", "Please provide a value in either the 'Assignee' or 'Group' field to queue this ticket.";

Question

What do I need to do to make the 'hasInput' method work with the Linked Issues field.  I have tried the following but with no luck:

if(hasInput("linkedIssues")) {
return true;
};

Does anyone know what that string needs to be?  And where I can see all the strings used for default Jira fields?  Also, can I extend that 'hasInput' method to also check that the user has specified the 'Is Blocked By' link type, as well as a ticket to link to?

1 answer

@Matt Albone  - I have asked vendor (cprime) the same question.

The answer was:

Hi Konstantin Iakovlev, sorry about this. We have supported the Linked Issues field in the past. However, for a while the HTML and CSS for this field would change every single time a new version of Jira was released and it became to much work to support a single field. Perhaps it is time to take another look. If you are trying to create a validator you can use Java Script like the code below. You would need to use Live Fields and use the lfExecuteJS() routine to call it.

 Hope this helps

Jonathan Muse
Product Manager

//Not used as far as I can tell, served as a base for the updated version in setDefectSource.js

AJS.$(document).ready(function($) { JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) { requireFields(); checkLinks(); }); function requireFields() { $('#issue-workflow-transition-submit').click(function() { var link = checkLinks(); }); } function checkLinks() { AJS.$("label:contains('Linked Issues')").append("<span class='aui-icon icon-required'>Required</span>"); $('#create-issue-submit, #issue-create-submit, #edit-issue-submit').click(function() { var size = AJS.$("#issuelinks-issues-multi-select.jira-multi-select > div.representation ul li").length; if (size == 0) { removeMessages(); AJS.messages.error(".form-body", { id: 'ps-message', body: '<p>You must have a link for this issue.</p>', insert: 'prepend', closeable: false }); return false; } else { removeMessages(); } }); } function removeMessages() { AJS.$(".aui-message-error").each(function() { if($(this).attr('id') == 'ps-message') { $(this).hide(); } }); } });

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Online AMA this week: Your project management questions answered by Jira Design Lead James Rotanson

We know that great teams require amazing project management chops. It's no surprise that great teams who use Jira have strong project managers, effective workflows, and secrets that bring planning ...

164 views 1 6
Read article

Atlassian Community Events