How to sync parent and children

We have an active sync from Jira cloud to Jira cloud (Different Atlassian organizations). We have separate connections for the parent sync (Feature) and child sync (Defect).

On the local site the parent issuetype is called “Feature” and the child is of type “Defect”. On the remote site the parent issuetype is called “Life Change Request” and child issuetype is “Bug”

We would like to make the parent\child relationships as created in local site also visible on the remote site.

Parent child relationships are established via OOtB Parent field in Jira

Following the documentation we extended the outgoing local script and incomming script on remote site for the Defect connection? Syncing Epics in Jira | Exalate Docs?

  • In outgoing script I’ve add: have added Epic.send()

  • In the incomming script on remote site Epic.receive()

For testing purposes I created local parent= PVA-79287 with child= PVA-49712. Both issues are synchronised and created on the remote site. Remote Parent issue = APGSAND-2035, remote child issue = APGSAND-2034

Unfortunately the hierarchy is not established on the remote site!!

json of local replica shows:

“customKeys”: {
“Epic Link”: {
“id”: 1596995,
“key”: “PVA-79287”
}
}

json of remote replica shows:

“customKeys”: {},

Do we need to make some additional configuration changes in the scripts to make this work?

Any help is appreciated.

Kind regards

Ron Becker (APG)

To sync parent-child relationships between different Jira Cloud instances using Exalate, you need to ensure that the relationship data (like the parent field or Epic Link) is correctly sent from the source and received/applied on the destination. Based on your description, it looks like the parent-child link isn’t being established on the remote side, even though both issues are created.

Here’s what you should check and adjust:

  1. Outgoing Sync Script (Source/Local):

    • You mentioned using Epic.send() in your outgoing sync script. This is typically used for syncing Epic relationships, but if your parent-child relationship is not based on Epics (for example, using the standard Jira parent field for sub-tasks or other issue links), you may need to explicitly send the parent information.
    • For standard parent-child (not Epic), you might need to add logic to send the parent key or ID in the replica, for example:
      if (issue.parent) {
        replica.customKeys['parentKey'] = issue.parent.key
      }
      
  2. Incoming Sync Script (Destination/Remote):

    • On the remote side, you need to receive this information and set the parent relationship accordingly. For example:
      if (replica.customKeys['parentKey']) {
        issue.parent = nodeHelper.getIssue(replica.customKeys['parentKey'])
      }
      
    • Make sure the parent issue is already created on the remote side before the child tries to link to it.
  3. Order of Synchronization:

    • The parent issue should be synchronized and created on the remote side before the child issue tries to establish the relationship. If the child syncs first, it won’t find the parent to link to.
  4. Custom Field Mapping:

    • If you’re using custom fields (like Epic Link or other custom parent fields), ensure the field IDs and names match between the two Jira instances, or handle the mapping in your scripts.
  5. Script Mode vs. Visual Mode:

    • Since you’re using Script mode, you have full control over what data is sent and received. Double-check that the scripts on both sides are correctly handling the parent-child data.
  6. Documentation Reference:

    • The documentation for syncing Epics in Jira Cloud is a good starting point: Syncing Epics in Jira | Exalate Docs. However, for non-Epic parent-child relationships, you may need to adapt the scripts as described above.

Summary:
You likely need to enhance your sync scripts to explicitly send and receive the parent issue key or ID, and then set the parent on the remote side. Double-check the order of synchronization and ensure the parent exists before the child tries to link to it.

For more details and script examples, see the official documentation:

If you need help with the exact script, let me know the specific parent-child relationship type (Epic, sub-task, or custom link), and I can provide a tailored example.

Our sync is really based on epic relationships. So epic\story would be the normal terminology. hierarchy on local site is:

Hierarchy on remote site is:

Hi Ron,

Thank you for sharing the details and the replica JSON. This helps clarify the issue.

The documentation you referred to covers synchronisation of Epic–Story relationships using the Epic Link field. However, since your setup uses Jira’s standard Parent field to establish the relationship between Feature and Defect issue types, the configuration needs to be slightly different.

For your use case, I would recommend using Jira’s parentId field instead of Epic.send() and Epic.receive().

1. Outgoing Sync – Local Jira (Defect connection)

Add the following to the outgoing sync script:

replica.parentId = issue.parentId

This sends the ID of the parent Feature along with the Defect replica.

2. Incoming Sync – Remote Jira (Defect connection)

On the remote side, you need to resolve the received parent ID to the corresponding synchronised parent issue and assign it to the remote Defect.

You can use the following logic:

if (replica.parentId) {
    def localParent = nodeHelper.getLocalIssueFromRemoteId(
        replica.parentId.toLong()
    )

    if (localParent) {
        issue.parentId = localParent.id
    } else {
        throw new com.exalate.api.exception.IssueTrackerException(
            "Parent issue with remote ID " + replica.parentId +
            " was not found. Please ensure that the parent issue is synchronised first."
        )
    }
}

3. Synchronisation sequence

Please also ensure that the parent Feature is synchronised before the child Defect. Since you are using separate connections for parent and child synchronisation, the corresponding parent issue must already exist on the remote Jira instance before the relationship can be established.

4. Existing synchronised issues

Since your test issues have already been synchronised, you may need to trigger another synchronisation after updating the scripts to apply the parent relationship. Also, ensure that the incoming logic is executed for existing issues and is not restricted only to the first sync.

For reference, you can find the relevant configuration in our documentation:

How to Sync Tasks and Subtasks in Jira Cloud

Although the example uses Tasks and Subtasks, the important part for your scenario is the use of replica.parentId and the resolution of the corresponding parent issue on the receiving side.

Please give this a try and let us know how it goes.

Thanks,
Dhiren

Hi Dhiren, Thanks for your help and detailed description. Currently my counterpart at the remote side is not available. I need to wait for him before we can test your suggestion. Once I know the result I’ll let you know.

Thanks again for your help

Kind regards

Ron