Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

IssueCreatedLinkEvent is not working

Rajakumar Sivakumar January 7, 2019

Hi Team,

I'm trying to update the security level while linking from "More".

I wanted the security level of the destination issue to be set as the source issue after linking.

I get run time error, after linking. 

Please find below my code and the error and kindly do the needful,

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.security.IssueSecurityLevelManager
import com.atlassian.jira.issue.security.IssueSecuritySchemeManager
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.fields.IssueLinksSystemField
import com.atlassian.jira.event.issue.IssueEvent

def IssueEvent event = event

def issue = event.issue as MutableIssue

 

def issueManager = ComponentAccessor.issueManager
def issueType = "Acquired Product Defect"
def linkedIssueType = "SRT Event"


def issueSecuritySchemeManager = ComponentAccessor.getComponent(IssueSecuritySchemeManager)
def issueSecurityLevelManager = ComponentAccessor.issueSecurityLevelManager
//def issueLinkManager = ComponentAccessor.getIssueLinkManager()

def SourceSecurityLevel = ComponentAccessor.getIssueSecurityLevelManager().getSecurityLevel(issue.getId())


def eventTypeManager = ComponentAccessor.getEventTypeManager();
def eventType = eventTypeManager.getEventType( event.getEventTypeId() );
def eventTypeName = eventType.getName();

if (issue.getIssueType().name == issueType) {
if( eventTypeName == "Issue Link Created" ){
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
issueLinkManager.getOutwardLinks(issue.id).each {issueLink ->
Issue linkedIssue = issueLink.getDestinationObject() as MutableIssue
if (linkedIssue.getIssueType().name == linkedIssueType) {
linkedIssue.setSecurityLevelId(SourceSecurityLevel.getId())

}
}
}
}

 

 

 

Error:

 

2019-01-07 07:51:18,973 ERROR [runner.AbstractScriptListener]: *************************************************************************************
2019-01-07 07:51:18,974 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.jira.event.issue.link.IssueLinkCreatedEvent, file: <inline script>
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'com.atlassian.jira.event.issue.link.IssueLinkCreatedEvent@10f49809' with class 'com.atlassian.jira.event.issue.link.IssueLinkCreatedEvent' to class 'com.atlassian.jira.event.issue.IssueEvent'
	at Script873.run(Script873.groovy:12)



Regards
Rajakumar Sivakumar
rajakumar.s@hcl.com

 

1 answer

0 votes
Tomasz Bryła
Contributor
January 8, 2019

Hi @Rajakumar Sivakumar,

What is yours Jira version? Try with:

import com.atlassian.jira.event.issue.link.IssueLinkCreatedEvent

And

Issue currentIssue = event.getIssueLink().getSourceObject()
Rajakumar Sivakumar January 9, 2019

Hi Tomasz,

The version of JIRA is 7.9.2

When I enter 

Issue currentIssue = event.getIssueLink().getSourceObject()

I get the below error, kindly suggest on this.


Listener Error.png

 

Regards
Rajakumar Sivakumar
rajakumar.s@hcl.com

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events