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
What is yours Jira version? Try with:
import com.atlassian.jira.event.issue.link.IssueLinkCreatedEvent
And
Issue currentIssue = event.getIssueLink().getSourceObject()
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.
Regards
Rajakumar Sivakumar
rajakumar.s@hcl.com
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.