Check if Epic is already synced in the local system

Originally asked by Ziad Qadora on 19 June 2020 (original question)


Hello,

When trying to sync a story before syncing the Epic, and I get an error. I’m trying to find out how to check if the parent Epic has been synced, and throw an error if it was not. Something like this which was done for Sub-Tasks

if (replica.parentId) {
def localParent =nodeHelper.getLocalIssueFromRemoteId(replica.parentId.toLong())
if(localParent){
issue.parentId = localParent.id
} else {
throw new com.exalate.api.exception.IssueTrackerException(issueType + " 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" )
}
}Source: Jira Server/Datacenter (old community)


Answer by Ziad Qadora on 19 June 2020

Hi Francis,

I did the follow the instructions in the epic sync

//Outgoing

//Epic Link
Epic.sendEpicFirst()
// Issue link sync
IssueLinks.send()
//Task Sync
SubTask.send()

//Incoming

// Move this to the end of the incoming sync script
SubTask.receive()
Epic.receive()

I do understand that we must sync the Epic first then the Story, but I want to print more meaningful message like the one for the sub-task

here is what I just added, but still do not see the error message

if (replica.epicId) {
def localEpic = nodeHelper.getLocalIssueFromRemoteId(replica.epicId.toLong())
if(localParent){
issue.epicId = localEpic.id
} else {
throw new com.exalate.api.exception.IssueTrackerException(issueType + " cannot be created: Epic issue with remote id " + replica.epicId + " was not found. Please make sure the epic issue is synchronized before resolving this error" )
}
}


Comments:

Francis Martens (Exalate) commented on 19 June 2020

Ha - I didn’t review if epicid is available. Need to find time to review

Answer by Francis Martens (Exalate) on 19 June 2020

Hi Ziad Qadora

It is identical, but then you need to test with the epic id

Did you try the epic sync external script

It should also cover this case.