Simple scripted validator for inward link

David Friedrich
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 7, 2017

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 8, 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

David Friedrich
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 11, 2017

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 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 September 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
TAGS
AUG Leaders

Atlassian Community Events