Synchronization above basic fields

Originally asked by Eva Konrad on 12 August 2020 (original question)


Dear All,

We have started use the exalate.
The synching of basic fields and links are working.

However, I cannot solve the next synchronizations:

- Fix Version (It is prepared in both system)
- Epic (you can see more version in the command lines which I used) but does not work. I used this documentation: https://docs.idalko.com/exalate/pages/viewpage.action?pageId=42631412
- Custom fields (it is prepared in both system) and I used this documentations and linked pages, but it does not work either:
https://docs.idalko.com/exalate/display/ED/How+to+Synchronize+Custom+Fields#HowtoSynchronizeCustomFields-text
- Isue type does not works trustworthy. I used https://docs.idalko.com/exalate/display/ED/How+to+synchronize+issue+type
- ParentID is unknown on destination side

Could you please help me and us on these topics?
Thank you in advance,
Eva

Attached the scripts:

*The outgoing sync* on source side
replica.key = issue.key
replica.type = issue.type
replica.reporter = issue.reporter
replica.summary = issue.summary
replica.description = issue.description
replica.labels = issue.labels
replica.comments = issue.comments
replica.resolution = issue.resolution
replica.status = issue.status
replica.parentId = issue.parentId
replica.priority = issue.priority
replica.attachments = issue.attachments
replica.project = issue.project

//Comment these lines out if you are interested in sending the full list of versions and components of the source project.
replica.project.versions =
replica.project.components =

//Custom Fields
replica.customFields.“Test results” = issue.customFields.“Test results”
replica.customFields.“Priority HL” = issue.customFields.“Priority HL”

// EPIC sync Ensure that the Epic is synced first, such that stories sent later can be associated to the right epic
Epic.send()

//Links
replica.issueLinks = issue.issueLinks

*The Incoming sync* on destination side
replica.key = issue.key
replica.type = issue.type
replica.reporter = issue.reporter
replica.summary = issue.summary
replica.description = issue.description
replica.labels = issue.labels
replica.comments = issue.comments
replica.resolution = issue.resolution
replica.status = issue.status
replica.parentId = issue.parentId
replica.priority = issue.priority
replica.attachments = issue.attachments
replica.project = issue.project

//Comment these lines out if you are interested in sending the full list of versions and components of the source project.
replica.project.versions =
replica.project.components =

//Custom Fields
replica.customFields.“Test results” = issue.customFields.“Test results”
replica.customFields.“Priority HL” = issue.customFields.“Priority HL”

// EPIC sync Ensure that the Epic is synced first, such that stories sent later can be associated to the right epic
Epic.send()

//Links
replica.issueLinks = issue.issueLinks


Comments:

Francis Martens (Exalate) commented on 13 August 2020

Lets take it one at a time, and create an answer for each topic?

Answer by Francis Martens (Exalate) on 13 August 2020

Isue type does not works trustworthy

Can you be more specific, and also provide the section ‘firstSync’ section of the incoming sync


Answer by Francis Martens (Exalate) on 13 August 2020

(It might be that the incoming sync section of your question is a wrong paste - but the explanation below applies for the causal reader)

Syncing of custom fields

Check the incoming sync where you have

//Custom Fields
replica.customFields."Test results" = issue.customFields."Test results"
replica.customFields."Priority HL" = issue.customFields."Priority HL"

The intent that in the incoming sync the logic is provided to populate the issue.

The way to assign a value to an issue field is with the assignment operator

<name of the variable to set the value> = <value to be set>

Like in

issue.summary = replica.summary

This assigns the summary (which is contained in the replica) to the summary of the issue.

Furthermore - the denotation

replica.customFields."Test Results" 

References a customField object (check here for more details). Such object has multiple attributes such as name, type, value …

Whenever you want to set the customfield value, you will have to use something like

issue.customFields."Test Results".value = replica.customFields."Test Results".value

Which reads as

Copy over the value of the customField ‘Test Results’ which is in the replica to the value attribute of the customField ‘Test Results’ of the issue under sync


Answer by Francis Martens (Exalate) on 13 August 2020

Fix version synchronization.

The approach is always the same.

  • send it from source
  • process it on destination

To send the fixVersion from source - just add it to the replica (which contains the payload which will be sent)

replica.fixVersions = issue.fixVersions

On the destination side, you need to update the local issue with the fixVersions.
Because the fixVersion on the source has a different id (and such) than the fixVersion on the destinations, you will have to look up the fixVersion.

You can use the nodeHelper.getVersion for this purpose. As the fixVersion is an array, you will have to loop through it. As fixVersions are specific to a project, getVersion will take a project as a kye

...
def project = nodeHelper.getProject(issue.projectKey)
issue.fixVersions = replica.fixVersions.collect {
                       remoteVersion ->

                       nodeHelper.getVersion(remoteVersion.name, project)
}

It could be that the version is not found. You can then either

  • Throw an error
  • Create the version
  • Add a comment to the issue
  • Ignore it

More details on this topic can be found at How to synchronize versions