How to add an existing issue under Related work items

When synching an issue I want to add acertain Related work item to my new created issue.

I tried several things but Exalate is not adding anything.

My latest code snippet:

issue.outwardLinks = (issue.outwardLinks ?: []) + [
    [
      relationship: "realize",
      key: "UTGPFM-10"
    ]
  ]

from manually linking an issue the XML states:

<issuelinks>
<issuelinktype id="10009">
<name>Realization</name>
<outwardlinks description="realize">
<issuelink>
<issuekey id="32261">UTGPFM-10</issuekey>
</issuelink>
</outwardlinks>
</issuelinktype>
</issuelinks>

Any idea how to add it in the incoming sync?

To add a specific “Related work item” (i.e., an issue link) during synchronization in Exalate for Jira, you should use the standard approach for syncing issue links in your sync rules. Your current code snippet is close, but Exalate expects you to work with the issueLinks property, not outwardLinks directly.

Here’s how you can do it in your incoming sync:

issue.issueLinks = (issue.issueLinks ?: []) + [
    [
      relationship: "realize",
      key: "UTGPFM-10"
    ]
]

This will add the “realize” relationship to the specified issue key. Make sure that the link type (“realize”) matches exactly with the link type configured in your Jira instance.

A few important notes:

  • The property to use is issue.issueLinks, not outwardLinks.
  • If you want to sync all links from the source, you can simply assign:
    issue.issueLinks = replica.issueLinks
    
  • If you want to merge with existing links, use the code above to append.

For more details, check the official documentation:
How to Sync Issue Links on Jira On-premise

If you want more advanced control (like mapping link types or preventing overwrites), Exalate also provides an external script approach. See:
IssueLinks.groovy

This should help you add related work items as part of your sync!

Unexpected error occurred. Generate an exalate support.zip file and contact support.

The solution is not helping.

Did anyone else figured out how to set Related work items?

Hi @DanielU ,

Welcome to the Exalate Community!

I will review your use case and update you back with suggestion soon.

Kind regards,
Ashar

Hi Ashar

Any news on this? Kind of annoying that I have to wait several days for answers and support is closing my ticket. When looking for new customers everybody is helping immediately and afterwards you are on your own.

Thanks for your help in advance

Hi @DanielU ,

I’ve tested this between two Jira cloud instances.

In this Incoming Sync snippet, a REST API call is used to create an issue link in Jira Cloud during the first sync.

import com.exalate.basic.domain.hubobject.v1.BasicHubIssueLink.IssueLinkType //add this line at the very beginning of Incoming Sync rule

if (firstSync)
store(issue)

httpClient.post(“/rest/api/3/issueLink”, new groovy.json.JsonBuilder([
type: [ name: “Relates” ],
inwardIssue: [ key: “TP-168” ],
outwardIssue: [ key: issue.key ]
]).toString())

It links the synced issue (issue.key) to a specific issue (TP-168) with the link type “Relates”.
So, whenever a new issue is synchronized, Jira automatically creates that relationship.

If this isn’t the linking behavior you’re trying to achieve, I’d be happy to arrange a quick call to understand your exact use case, and then provide a suitable solution here in this post.

Outgoing Sync rule:

replica.issueLinks = issue.issueLinks

Kind regards,

Ashar

Important: there has to be the definition of projectKey and issueType before you add the code from Ashar.

@ashar.iqbal thank you for your help!

1 Like