You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.
View groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
Hi,
I created a script that sets specified value in Y custom field when I set specified value in X field.
X field is "Epic Link" (type: Epic Link Relationship) and Y it "Organizational Unit" field (type: Select List (single choice).
When I set constant issue key, script works correctly, but when I place script in Script Listener and set Events to "IssueLinkCreatedEvent" my script don't see a current issue.
In console I get information about null object.
How I can get current editing issue in this case?
Actually I try get current issue by code:
Issue issue = issue.
I tried also this method:
Issue issue = (Issue)jiraHelper.getContextParams().get("issue");
but that did not help.
Unfortunately, I receive this error:
2018-09-04 13:50:57,414 ERROR [runner.AbstractScriptListener]: ************************************************************************************* 2018-09-04 13:50:57,430 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.jira.event.issue.link.IssueLinkCreatedEvent, file: <inline script> groovy.lang.MissingPropertyException: No such property: issue for class: com.atlassian.jira.event.issue.link.IssueLinkCreatedEvent at Script316.run(Script316.groovy:9)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh, this is IssueLink event.
Is contains IssueLink object, which have methods to retrieve source and destination issues
Issue destinationIssue = event.getIssueLink().getDestinationObject()
Issue sourceIssue = event.getIssueLink().getSourceObject()
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.
Issue destinationIssue = event.getIssueLink().getDestinationObject()
Issue sourceIssue = event.getIssueLink().getSourceObject()
I use this code, but it doesn't work for me.
Can anybody help?
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.
I managed to resolve it:
Issue issue = null; //Indicates a new Issue Object, without this event. doesn't seems to work
if(event.getClass().toString() == "class com.atlassian.jira.event.issue.link.IssueLinkCreatedEvent"){ // Need some way to check if link is created or deleted, i saw something like this: (event instanceOf issueLinkCreatedEvent) but this didn't work for me
def event = event as IssueLinkCreatedEvent
issue = event.getIssueLink().getSourceObject()
} else if(event.getClass().toString() == "class com.atlassian.jira.event.issue.link.IssueLinkDeletedEvent"){
def event = event as IssueLinkDeletedEvent
issue = event.getIssueLink().getSourceObject()
} else issue = issue; //In my code, I am using also "Issue updated" event, if you want only check if Link is created or deleted, just erase this
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did that code work for you? Your comments are saying something differently and I get a:
unable to resolve class IssueLinkCreatedEvent
Can you also post your import section?
Best
Daniel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Now I know. What is often missing for beginners - which class to import. In this case do
import com.atlassian.jira.event.issue.link.IssueLinkCreatedEvent
import com.atlassian.jira.event.issue.link.IssueLinkDeletedEvent
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi i have this problem to, i want to delete issue link when user want to create link to another project,and user only can link issue to current project that issue is in,i try this code
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.project.Project;
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.event.issue.EventUtils
//import com.atlassian.jira.event.issue.link.IssueLinkCreatedEvent
Issue issuedes = event.issue;
Issue issuesou;
ProjectManager projectMgr = ComponentAccessor.getProjectManager();
//Issue destinationIssue = IssueLink.getDestinationObject()
//Issue sourceIssue = IssueLink.getSourceObject()
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
Issue currentIssue = issuesou
//def currentProject = currentIssue.projectObject.name
def linkedIssue = issuedes
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
issueLinkManager.getOutwardLinks(currentIssue.id).each { issueLink ->
linkedIssue = issueLink.getDestinationObject()
if( linkedIssue.getProjectObject().getKey() != currentIssue.getProjectObject().getKey() )
{
issueLinkManager.removeIssueLink(issueLink, user)
}
}
and i have this error
2019-01-08 11:21:03,878 ERROR [runner.AbstractScriptListener]: ************************************************************************************* 2019-01-08 11:21:03,878 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.jira.event.issue.IssueEvent, file: <inline script> java.lang.NullPointerException: Cannot get property 'id' on null object at Script3086.run(Script3086.groovy:23)
i think i can not refer to sourceIssue and event.issue; code is for destinationIssue,
please help me thank
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Issue issuesou;
This indicated null object
Then:
Issue currentIssue = issuesou
So when you try to do this:
issueLinkManager.getOutwardLinks(currentIssue.id).each
It causes the problem, it cannot do anything on null object.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.