Delete remote link when archiving an issue

We sync issues between Jira Software 10.3.6 and Jira Service Management 10.3.6 using Exalate 5.28.1-java17-j10

When an user archive an issue with a remote link, the Exalate support recommend us to disconnect both issues BEFORE archiving. But the users doesn’t has permission to unexalate remote links. So, in order to avoid future errors, we must find a way to DELETE a remote link when an issue is archived. I programed a listener using ScriptRunner that executes in the “Issue Archived” event. The listener then executes a code, and the remote link dissapear from the archived issue, but not from the remote issue. The code is the following:

    static void disconnectIssue(String key) {
        def targetIssue = ComponentAccessor.issueManager.getIssueObject(key)
        if (targetIssue) {
            def ttRepo = ComponentAccessor.getOSGiComponentInstanceOfType(ITwinTraceRepository.class)
            ttRepo.findByLocalIssueKey(new BasicIssueKey(targetIssue.id as Long, targetIssue.key)).each {
                ttRepo.deleteTwinTrace(it)
            }
        }
    }

¿How can I delete the remote link from both issues?

Great question! You’re on the right track with your ScriptRunner listener for the “Issue Archived” event, but as you’ve noticed, deleting the local twin trace only removes the remote link from the archived issue—not from the remote (counterpart) issue.

To fully disconnect both issues and remove the remote links on both sides, you need to ensure that the disconnection is performed bi-directionally. Exalate’s recommended approach is to use the “Unexalate” (disconnect) operation, which safely removes the sync relationship and remote links from both issues. However, this operation typically requires user permissions.

Since your users don’t have permission to unexalate, and you want to automate this via a listener, you’ll need to trigger the disconnect operation programmatically on both sides. Unfortunately, directly deleting the twin trace only affects the local side and doesn’t notify the remote instance to clean up its link.

Here’s what you should consider:

  • The Exalate REST API provides a way to disconnect issues programmatically. You can call the Disconnect Issue API to remove the sync and remote links from both sides.
  • You’ll need to call this API from your listener, passing the local issue key or ID. This will ensure both issues are properly disconnected and all remote links are removed.

Example approach:

  1. In your ScriptRunner listener, when the “Issue Archived” event fires, make an HTTP POST request to the Exalate REST API endpoint for disconnecting the issue.
  2. The API will handle the cleanup on both the local and remote issues.

Reference:
You can find more details on the disconnect API here:
https://docs.exalate.com/docs/rest-api-disconnect-an-issue

Important:

  • Make sure your ScriptRunner code has the necessary permissions and authentication to call the Exalate REST API.
  • This approach is more robust than deleting the twin trace directly, as it ensures both sides are cleaned up.

By using the Exalate REST API for disconnection, you’ll avoid future sync errors and keep both Jira instances tidy when issues are archived.