Script Listener to purge the value of a custom field from an issue when that issue is unlinked

SWAPNIL SRIVASTAV August 7, 2019

When an issue is unlinked/delinked in JIRA, I want to fetch the value of a particular custom field in that issue and delete its value.

1 answer

1 accepted

1 vote
Answer accepted
Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 7, 2019

Hello @SWAPNIL SRIVASTAV 

You can write a custom listener with script runner plugin which should listen to the event "IssueLinkDeleted" and in the listener you can update the custom field value for the issue as null.

Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 7, 2019

And here's the API for the event, from the event object you can get issueLink and from issueLink you can get sourceObject and destinationObject thus you will get objects of both issues involved.

https://docs.atlassian.com/software/jira/docs/api/7.6.1/com/atlassian/jira/event/issue/link/IssueLinkDeletedEvent.html

Like SWAPNIL SRIVASTAV likes this
SWAPNIL SRIVASTAV August 7, 2019

Hello @Tarun Sapra ,

Yes, I tried the same. But, I am not able to fetch the issue ID of unlinked issue in the script listener. Could you please let me know how to do that.

Thanks,

Swapnil Srivastav

SWAPNIL SRIVASTAV August 7, 2019

Also, I have two JIRA instances, The IssueLinkDeletedEvent is available in only one instance. Could you have any idea why is that?

Thanks,

Swapnil Srivastav.

Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 7, 2019

The even was introduced in 7.5 i think, hence one JIra instance can be an earlier version of Jira.

The even object in the listener should return to you the issueLink and using issueLink you can get source and destination object both.

Like SWAPNIL SRIVASTAV likes this
SWAPNIL SRIVASTAV August 7, 2019

@Tarun Sapra ,

Oh, I see. Ok, I am trying the script listener in one instance, one with version 7.6.6. Is there any alternative for the jira instance with version earlier of 7.5, mine is 7.4.4 to be precise. Any help would be appreciated.

Thanks and Regards,

Swapnil Srivastav.

SWAPNIL SRIVASTAV August 8, 2019

Got the script listener working for instance 7.6.6. Still open to any possible alternatives for version 7.4.4

Suggest an answer

Log in or Sign up to answer