I have not made any changes to Jira.
We have setup workflow for our Change Control project which should force the issue to link an issue - but I can't figure out how to do it. We need to force the user to select a RELATED link.
I have setup a validator to use Script Runner without success:
ScriptRunner workflow function - Simple scripted validator (condition apply).
issueLinkManager.getOutwardLinks(issue.getId())*.issueLinkType.name.contains('Relates')
I have also tried many other iterations of the word "RELATES:
Once I publish the workflow and test, I link an issue as RELATED to another issue but it never passesCapture.PNGes.
Use the simple scripted validator with the condition below to get the inward and outward links, it should be in that:
issueLinkManager.getIssueLinks(issue.getId())*.issueLinkType.name.contains('Relates')
or to only get the inward ones (which is likely your case with "Relates") use:
issueLinkManager.getInwardLinks(issue.getId())*.issueLinkType.name.contains('Relates')
Hope this helps,
Adam
This worked:
issueLinkManager.getInwardLinks(issue.getId())*.issueLinkType.name.contains(
'Relates'
)
Thanks!
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.
Did you try saving and testing it? SR static checker might be weird sometimes.
What version of JIRA are you using?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I did not - will do now...I figured there was an error so I didn't move forward...
Our JIRA is locally hosted v7.2
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.
Something like this should do the job:
import com.atlassian.jira.bc.issue.link.IssueLinkService import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.issue.fields.IssueLinksSystemField MutableIssue issue = issue def value = (IssueLinksSystemField.IssueLinkingValue) issue.getModifiedFields().get("issuelinks").newValue if (value) { IssueLinkService.AddIssueLinkValidationResult validationResult = value.validationResult return validationResult.linkType.name == "Relates" && validationResult.linkKeys } else { return false }
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.
Try this code:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.link.IssueLink for(IssueLink link: ComponentAccessor.getIssueLinkManager().getIssueLinks(issue.getId())){ if(link.getIssueLinkType().getName().equals("RELATED")) return true } return false;
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.
Could you provide exact name of this issue link type?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I haven't made any changes to this - so it's all stock:
image2016-10-24 9:42:4.png
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I also tried changing this line to the exact case as the link name:
if
(link.getIssueLinkType().getName().equals(
"Relates"
))
Still won't pass.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, it is my mistake, try this code:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.link.IssueLink import com.atlassian.jira.issue.link.IssueLinkManager IssueLinkManager issueLinkManager = ComponentAccessor.getIssueLinkManager(); for(IssueLink link: issueLinkManager.getOutwardLinks(issue.getId())){ if(link.getIssueLinkType().getName().equals("Relates")) return true } for(IssueLink link: issueLinkManager.getInwardLinks(issue.getId())){ if(link.getIssueLinkType().getName().equals("Relates")) return true } return false;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Should this be doubled up like this?:
for
(IssueLink link: issueLinkManager.getInwardLinks(issue.getId())){
if
(link.getIssueLinkType().getName().equals(
"Relates"
))
return
true
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hm, you are right. In this case it is not requred to double
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.
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.link.IssueLink import com.atlassian.jira.issue.link.IssueLinkManager for(IssueLink link: ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId())){ if(link.getIssueLinkType().getName().equals("Relates")) return true } return false;
This will work for simple script condition.
For custom script condition it will be slightly more different.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't understand what I am doing wrong - I agree that your code should work - but after I add a related link I still get this:
image2016-10-26 8:1:47.png
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do you use this code for simple script condition?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here are my steps:
image2016-10-26 8:3:9.png
image2016-10-26 8:3:35.png
image2016-10-26 8:3:58.png
image2016-10-26 8:4:46.png
What the heck!?!?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could you check this validator on some issue with preview?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hmmm not sure how to do that - can you point me in the right direction?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try this script into Script Console. Replace issueKey with key of tested issue:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.link.IssueLink Issue issue = ComponentAccessor.getIssueManager().getIssueObject("issueKey") for(IssueLink link: ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId())){ if(link.getIssueLinkType().getName().equals("Relates")) return true } return false;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I changed issueKey to an issue that I know does not have a related link, run the preview and this is what I get:
image2016-10-26 9:19:5.png
Not much of any feedback from the script.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You need to run this script here: admin panel/plugins/scriptrunner/script console.
And as the result you will get true or false.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online 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.