Simple scripted validator for inward link

Hi,

using JIRA 6.3.13 and Scriptrunner 3.1.4 I'd like to add a simple scripted validator doing the following:

If there are incoming links of linktype "Teilprojekt" the linked issue(s) must NOT be "Open" for carrying out the transition. Link discription for incoming link is "is Teilprojekt of".

Very important: the validator should only check incomming, but not outgoing links.

 

Thank you!

1 answer

0 votes
Jenna Davis Community Champion Sep 08, 2017

Hello, 

I think that something like this will work for you:

import com.atlassian.jira.component.ComponentAccessor

def issueLinkManager = ComponentAccessor.issueLinkManager
def inwardLinks = issueLinkManager.getInwardLinks(issue.id)

inwardLinks.each {
if (it.issueLinkType.name == "Teilprojekt") {
if ((it.sourceObject.status as String) == 'Open') {
return false
}
}
else return true
}

I did not test out the code directly, but I believe it should work. If something isn't working out please do not hestitate to come back and ask. :)

Regards, 
Jenna

Hi Jenna,

thank you very much for looking into this one. But I am sorry. It is not working. The transition is not blocked.

Jenna Davis Community Champion Sep 20, 2017

Sorry for my belated reply!

Were you able to get this to work? If not, do you see any errors?

Regards, Jenna

Erin I'm New Here Sep 11, 2018

Hi @Jenna Davis, I am trying to do something similar but instead of Validator, I'm using post function. 

The use case is - Whenever I clone an issue, I would like the new ticket to not have the old ticket's Due date field. I used the code below. The code runs without any errors but the Due Date value is still not cleared. Would you tell what I'm doing wrong?

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.fields.IssueLinksSystemField
import webwork.action.ActionContext
import java.sql.Timestamp

def fieldManager = ComponentAccessor.getFieldManager()
def issueLinkManager = ComponentAccessor.issueLinkManager
def inwardLinks = issueLinkManager.getInwardLinks(issue.id)

inwardLinks.each {
if (it.issueLinkType.name == "is cloned by") {
issue.setDueDate(null)

}
}

 

Thanks

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 29, 2018 in Marketplace Apps

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,396 views 0 8
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you