Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

IssueLinkCreatedEvent doesn't have either parent issue or issue-link type information

Hello Everyone,

I am trying to develop a scriptrunner script that will delete issue-links on the issue that calls the IssueLinkCreatedEvent. This deletion has to check some requirement in the main issue but i am not able to always get the correct main issue.

This is because of 2 reasons:

1. The IssueLinkCreatedEvent does not have any information about the issue that has fired the IssueLinkCreatedEvent, so the following line will give back a null because the event does not contain a issue object:

Issue issue = event.issue


2. The event also doesn't contain the direction of an issue-link creation:

I know i can get the source and destination object by the following code

IssueLink issueLink = event.issueLink
Issue issueDestination = issueLink.destinationObject()
Issue issueSource = issueLink.getSourceObject()

But the problem is when you select outward or inward type of the link the destination and source will swap issue id's. Because of this i cannot get the main parent issue out because the IssueLinkCreatedEvent also doesn't provide information on which direction the link is going!

For example if i have a issuelink with:

Name: Test
Outward: Tests
Inward: Is tested by

The IssueLinkCreatedEvent does not contain the direction of a outward or inward issue-link.  

Two possible solutions that will solve my issue:

1. Does someone have any idea how to get the issue that fires the IssueLinkCreatedEvent!

or

2. Is there a way to get or provide the IssueLinkCreatedEvent with the correct direction it is going ? for example how to know if it is "is tested by" or  "Tests"

 

1 answer

0 votes

Hello @Bart_Joosten

I believe your problem was solved in this thread :) 
https://community.atlassian.com/t5/Jira-questions/How-to-get-current-issue-when-I-use-IssueLinkCreatedEvent-event/qaq-p/879597

See the accepted solution 🚀

The answer on that thread did not give me the correct solution:

I am looking for the main parent object that is firing the event and not the source or destination object Issues.

Because when you change the link type from inward to outward they will swap there place of the id's. 

So from the SourceID or DestionationID i cannot get which one is the main issue that is execution the event, for example: 

I have a issue called Issue-1 and want to link this issue to Issue-2:

When i select the link type Tests(Inward), the source and destination id will be:

SourceID:               700 (Issue-1)
DestionationID:   800 (Issue-2)

but when i select the link type Is tested by(Outward) it will be:

SourceID:               800 (Issue-2)
DestionationID:   700 (Issue-1)

So how can i get the issue that is firing the event when it is in the first link type the SourceID but in the counter action it is the DestionationID?

And the event is not giving me back if it is doing the outward or inward action of the issuelink?

So it would be help full if the IssueLinkCreatedEvent would have the id or key of the issue that is firing the event. Or if it would have the name of the inward or outward link it is executing!

Hope it's more clear now!

Like Fernando Bordallo likes this

Hello @Bart_Joosten

From what I see in the ScriptRunner docs the information about the issue from which the event is being fired is not available. I understand this makes sense given you are listening to the creation of a Link between issues, which can be done both explicitly through UI from one issue to another or through scripts or API calls, scenarios in which there is no defined 'origin issue' (so to speak).

What are you trying to accomplish exactly?

Like Bart_Joosten likes this
Like Bart_Joosten likes this

Hi @Fernando Bordallo

Actions:

  1. User is working one issue-1 
  2. In issue 1 the user is creating a issue-link to issue 2

Question:

  1. While listening on IssuelinkCreatedEvent how to get the "ID" or "Key" of issue 1
  2. While listening on IssuelinkCreatedEvent it is now not showing the inward or outward action that the user has selected while creating issuelink, for example "Tests" or "Is Tested by". How to get this value?

image.png

 

The current values that the event is given and where you can transform them into:

ID:                                       Current issue-link id that is counting up 

SourceID:                        Issue object: Source issue

DestionationID:            Issue object: Destination issue 

IssuelinkType:               The name of the issuelink: Test         


I want to know the issue object that the user is calling the IssuelinkCreatedEvent on or the issuelinktype that he is using, at this moment the event does not supply this information. because i only want to allow specific types of links on issue 1 i need to know the type of the link he is creating or on which ticket he is creating the issuelink on.

Because the DestionationID and SourceID are different on the type of link you have selected i can never tell my scriptrunner script what is the main issue he needs to check the links on.  

So i think the event is missing a parameter of the current issuekey or the issuelinkType parameter is to global and is giving only back the name and should be giving back the type inward or outward! for example 2 events that should solve the problem whit if they would provide one of the following parameters:

Current event is giving back:

eventissuelink:com.atlassian.jira.issue.link.IssueLinkImpl@456f4236[id=170506,sourceId=212096,destinationId=211890,issueLinkType=10700]

Should be one of the following:

eventissuelink:com.atlassian.jira.issue.link.IssueLinkImpl@456f4236[id=170506,sourceId=212096,destinationId=211890,issueLinkType=10700,issuelinkDescription=[Tests] Or [IsTestedby]]

eventissuelink:com.atlassian.jira.issue.link.IssueLinkImpl@456f4236[id=170506,sourceId=212096,destinationId=211890,issueLinkType=10700,ExecutionIssue=[Issue1]]

 

 

Hi @Fernando Bordallo

Actions:

  1. User is working one issue-1 
  2. In issue 1 the user is creating a issue-link to issue 2

Question:

  1. While listening on IssuelinkCreatedEvent how to get the "ID" or "Key" of issue 1
  2. While listening on IssuelinkCreatedEvent it is now not showing the inward or outward action that the user has selected while creating issuelink, for example "Tests" or "Is Tested by". How to get this value?

image.png

 

The current values that the event is given and where you can transform them into:

ID:                                       Current issue-link id that is counting up 

SourceID:                        Issue object: Source issue

DestionationID:            Issue object: Destination issue 

IssuelinkType:               The name of the issuelink: Test         


I want to know the issue object that the user is calling the IssuelinkCreatedEvent on or the issuelinktype that he is using, at this moment the event does not supply this information. because i only want to allow specific types of links on issue 1 i need to know the type of the link he is creating or on which ticket he is creating the issuelink on.

Because the DestionationID and SourceID are different on the type of link you have selected i can never tell my scriptrunner script what is the main issue he needs to check the links on.  

So i think the event is missing a parameter of the current issuekey or the issuelinkType parameter is to global and is giving only back the name and should be giving back the type inward or outward! for example 2 events that should solve the problem whit if they would provide one of the following parameters:

Current event: 

eventissuelink:com.atlassian.jira.issue.link.IssueLinkImpl@456f4236[id=170506,sourceId=212096,destinationId=211890,issueLinkType=10700]

Solving event 1:

eventissuelink:com.atlassian.jira.issue.link.IssueLinkImpl@456f4236[id=170506,sourceId=212096,destinationId=211890,issueLinkType=10700,issuelinkDescription=[Tests] Or [IsTestedby]]

Solving event 2:

eventissuelink:com.atlassian.jira.issue.link.IssueLinkImpl@456f4236[id=170506,sourceId=212096,destinationId=211890,issueLinkType=10700,ExecutionIssue=[Issue1]]

Like Fernando Bordallo likes this

Hello again @Bart_Joosten

I see what you are trying to do. As I stated before I don't think listening to the issueLinkCreated is the correct approach to obtain this information as this event cannot contain the information on the issue the link is created from with a 100% correctness.

I believe your best solution would be to listen to issueUpdated events and look into the changelog to see if the update relates to a new issueLink having been created.

@Fernando Bordallo 

The issue update event does not get triggered when you are creating a link because the event IssueLinkCreatedEvent will not call a issue update event somehow. So this action is not possible any other solutions?

Hi @Bart_Joosten, thanks for bringing this to the attention of Adaptavist Support. I believe @Fernando Bordallo is right to identify this question as relating more to the Jira APIs than to ScriptRunner specifically: there is no way for SR to retrieve the information you seek because Jira simply does not record it. IssueLinkCreatedEvent is not an exclusively issue-related event (i.e. it does not arise solely from the creation/updating/transition/etc. of a single issue) and thus identifying it with one issue is not always semantically appropriate. I do agree that in situations where such an identification does make sense, it would be useful information to have, but this is something to address to Atlassian.

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you