} else { throw new com.exalate.api.exception.IssueTrackerException("Subtask cannot be created: parent issue with remote id " + replica.parentId + " was not found. Please make sure the parent issue is synchronized before resolving this error" ) }
}
However, if try the following snippet in order sync the subtasks automatically, the subtasks do not get synced:
Added the following in the JoP outgoing:
// Automatically sync all subtasks when syncing parent task httpClient.get("/rest/api/3/issue/"+issueKey.id).fields.subtasks?.collect{ def subTaskKey = new com.exalate.basic.domain.BasicIssueKey(it.id, it.key) syncHelper.exalate(subTaskKey) }
All the snippets are being taken from this article:
Great question! You’re on the right track with syncing subtasks between Jira On-Prem and Jira Cloud, and you’ve referenced the correct documentation. Let’s break down what’s happening and how to get the automatic subtask sync working smoothly.
What’s working:
Manual or trigger-based subtask sync works fine.
Your outgoing and incoming sync scripts for parent/child relationships are set up as per the docs.
What’s not working:
When you try to automatically sync all subtasks by adding the syncHelper.exalate(subTaskKey) logic in the outgoing script, the subtasks don’t sync as expected.
Why this happens:
The main reason is that the syncHelper.exalate() function only works if the Exalate app has access to the subtasks you’re trying to sync. In Jira On-Prem, the REST API endpoint you’re using (/rest/api/3/issue/) is for Jira Cloud, not Jira Server/Data Center. For Jira On-Prem, you should use the appropriate REST API endpoint and field structure.
How to fix it:
Use the correct REST API endpoint for Jira On-Prem:
For Jira Server/Data Center, the endpoint should be /rest/api/2/issue/ instead of /rest/api/3/issue/.
Adjust the script for Jira On-Prem:
Here’s how you can modify your outgoing sync script for Jira On-Prem:
// Automatically sync all subtasks when syncing parent task
def response = httpClient.get("/rest/api/2/issue/${issueKey.id}")
def subtasks = response.fields?.subtasks
subtasks?.each {
def subTaskKey = new com.exalate.basic.domain.BasicIssueKey(it.id, it.key)
syncHelper.exalate(subTaskKey)
}
This script fetches the subtasks for the parent issue and triggers Exalate for each subtask.
Make sure permissions are correct:
The Exalate app user must have permission to view the parent issue and its subtasks.
Parent must be synced first:
Subtasks can only be created if their parent exists on the destination. Your incoming script already checks for this, which is perfect.
Summary:
Update your outgoing script to use the correct API endpoint for Jira On-Prem, and ensure the Exalate user has the right permissions. This should get your automatic subtask sync working as expected.
Hope this clears things up and gets your sync running smoothly!