Signature
Helper | syncHelper |
Signature |
|
Description |
Use this helper method in the Incoming sync to update the source issue once the synchronization to the destination side is finished. |
Introduced in | 4.6.5 |
Using the Feature
Assume
- you have 2 instances 'Internal' and 'External'.
- You raise an issue on 'Internal', and exalate it to 'External'
- You need to have a custom field on Internal containing the remote key of the issue created on External
What needs to happen is
- Once that the issue is created on External, a message is sent back to Internal containing the key of the created issue
- The syncHelper.syncBackAfterProcessing() triggers this message as it queues a sync event which is handled as if the issue on external has been changed
- The processing of this sync event is identical to any other sync event
What you need to configure:
On the destination side (external) in the incoming sync processor
// trigger a sync back to the internal instance if(firstSync){ syncHelper.syncBackAfterProcessing() }
On the source side (internal) in the incoming sync processor
// update the custom field 'remote issue key' with the key of the newly created issue issue.customFields."remote issue key".value = replica.key
Warning: Method syncHelper.syncBackAfterProcessing() only works for the bidirectional synchronization. Using it for the unidirectional sync might lead to unexpected sync errors.
Warning: Using syncHelper.syncBackAfterProcessing() outside the firstSync if block might cause infinite loops.
Avoiding conflicts
A sync conflict is possible whenever changing information on the source issue immediately after an exalate.
Source Jira | Target Jira |
---|---|
Exalate issue
Status is 'open' |
|
|
Create issue
Status is 'Open' |
Change status to 'In Progress |
|
|
Syncback issue
Status is open |
Syncback is processed
Status is changed back to 'Open' |
|
|
Status is updated to 'In Progress' because of message sent in step 3 |
Status = Open | Status = 'In Progress' |
|
|
To avoid this conflict, one can add this code
if (!firstSync && previous?.status.name == replica?.status.name) { // do not update the status as it might conflict }