This article shows how to stop the sync automatically once the issue has been moved to another project.

Introduction

The synchronization is set up to sync issues form the specific project automatically.

Now, if the issue has been moved from the project under sync to another project which has a different workflow, the synchronization should be stopped automatically.

You can configure the synchronization behavior in different ways to achieve this:

Jira Server

Continue sync, but don't apply any changes if the issue has been moved to another project 

 Use this approach if moved issues might be moved back at some point of time. 

Source side

Change processors

if (issue.project.key != "HELP") { 
  // don't apply any changes if the local issue has been moved from the HELP project
  return 
}
// the rest of the script remains untouched and goes after this `if`
// ...


Destination side  

Create Processor

 

 if (replica.project.key != "HELP") { 
  return 
}
// the rest of the script remains untouched and goes after this `if`
// ...
 

Change processor

if (replica.project.key != "HELP") { 
  // don't apply any changes if the remote issue has been moved from the HELP project
  return 
}
// the rest of the script remains untouched and goes after this `if`
// ...

Stop the sync if the issue has been moved to another project

Use this approach if moved issues would not be moved back at some point of time.

If the issue is moved back, it triggers sync once again by creating new twin issue.

Source side

Change Processor

if (issue.project.key != "HELP") { 
  // stop sync if the local issue has been moved from the HELP project
  final def _syncInitService = com.atlassian.jira.component.ComponentAccessor
    .getOSGiComponentInstanceOfType(com.exalate.api.trigger.ISyncInitiationService.class)
  _syncInitService.unexalate(issueKey.id as Long)
  return 
}
// the rest of the script remains untouched and goes after this `if`
// ...
 

Destination side

Create Processor

if (replica.project.key != "HELP") { 
  return 
}
// the rest of the script remains untouched and goes after this `if`
// ...
 

Change Processor

if (replica.project.key != "HELP") { 
  // stop sync if the local issue has been moved from the HELP project
  final def _syncInitService = com.atlassian.jira.component.ComponentAccessor
    .getOSGiComponentInstanceOfType(com.exalate.api.trigger.ISyncInitiationService.class)
  _syncInitService.unexalate(issueKey.id as Long)
  return 
}
// the rest of the script remains untouched and goes after this `if`
// ...
 

Jira Cloud

Continue sync, but don't apply any changes if the issue has been moved to another project 

 Use this approach if moved issues might be moved back at some point of time. 

Source side

Change processors

if (issue.project.key != "HELP") { 
  // don't apply any changes if the local issue has been moved from the HELP project
  return 
}
// the rest of the script remains untouched and goes after this `if`
// ...


Destination side  

Create Processor

 

 if (replica.project.key != "HELP") { 
  return 
}
// the rest of the script remains untouched and goes after this `if`
// ...
 

Change processor

if (replica.project.key != "HELP") { 
  // don't apply any changes if the remote issue has been moved from the HELP project
  return 
}
// the rest of the script remains untouched and goes after this `if`
// ...

Stop the sync if the issue has been moved to another project

Use this approach if moved issues would not be moved back at some point of time.

If the issue is moved back, it triggers sync once again by creating new twin issue.

Source side

Change Processor

if (issue.project.key != "HELP") {
    // stop sync if the local issue has been moved from the HELP project
    def _injector = play.api.Play$.MODULE$.current().injector()
    final def _syncInitService = _injector.instanceOf(com.exalate.replication.services.api.replication.IEventSchedulerService.class)
    _syncInitService.scheduleUnexalateEvent(relation, issueKey)
    return
}
// the rest of the script remains untouched and goes after this `if`
// ...
 

Destination side

Create Processor

if (replica.project.key != "HELP") { 
  return 
}
// the rest of the script remains untouched and goes after this `if`
// ...
 

Change Processor

 if (replica.project.key != "HELP") {
    // stop sync if the local issue has been moved from the HELP project
    def _injector = play.api.Play$.MODULE$.current().injector()
    final def _syncInitService = _injector.instanceOf(com.exalate.replication.services.api.replication.IEventSchedulerService.class)
    _syncInitService.scheduleUnexalateEvent(relation, issueKey)
    return
}
// the rest of the script remains untouched and goes after this `if`
// ...