Hello,
I'm using the ScriptRunner plugin from adaptavist, specifically script function "Clones an issue and links".
I have no experience in Java & Groovy (I'm not a programmer) at all but I would like to write a simple "Condition" that will only process the function if there are no existing links to the issue. Link type does not matter much but it would be preferable if I could check to see if the link type is "is blocked by" .
I tried to use the example code and modify it a bit:
issueLinkManager.getOutwardLinks(issue.getId())*.issueLinkType.name.contains!('is blocked By')
But when I use this condition, no action is performed even though the ticket has not any links with the type "is blocked by". What am I doing wrong?
Thanks,
Baybars
Community moderators have prevented the ability to post new answers.
The name will be something Blockers. The inward or outward description might be "is blocked by". You should check at Admin -> Issue Linking or whatever it is.
So a condition would be:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.link.IssueLinkManager def issueLinkManager = ComponentAccessor.getComponent(IssueLinkManager) ! issueLinkManager.getOutwardLinks(issue.getId()).any { it.issueLinkType.name == "Blockers" }
I've changed the name of "Blockers" to "is blocked by" (this is what I understood from your post), the syntax is correct but it still performs the script even if the issue has been linked to another issue.
Is there a method to see if the condition we've set actually is met or not for the issue?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
From Issue Linking you shd see something like: image2016-4-21 19:50:54.png
The highlighted thing is the name, it's almost certainly not "is blocked by".
If that doesn't work maybe you want getInwardLinks, depending on what you're trying to do.
IIRC the simple scripted condition lets you trial the condition with a sample issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Jamie , it worked with "getInwardLinks" .
Can you elaborate on: "IIRC the simple scripted condition lets you trial the condition with a sample issue." This would be very useful for the future.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Baybers,
I think Jamie is referring to the Preview button available in the Scripted Post Function when you choose "Clone & Link".
I just tried it and the Preview button does not accept a sample issue as a parameter (on this occasion).
There are many scenarios where the Preview button does let you input an issuekey so you can try it out.
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.
Hi,
Have you tried this:
if(!issueLinkManager.getOutwardLinks(issue.getId())*.issueLinkType.name.contains('is blocked By') )
That means that issue LinkType isn't "is blocked By"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
this did not work, it did not like the if statement. I think because this already is a "condition", you don't need a if statement.
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.