Answer by Francis Martens (Exalate) on 10 September 2020
https://docs.idalko.com/exalate/display/ED/How+to+synchronize+issue+links+to+a+custom+field
This is the way to do it.
- Collect all information into a custom field or custom key
- Sync it over
- Apply it on the cloud side.
> But had no success
If you provide details, we can see if we can help
Comments:
Vygandas commented on 10 September 2020
Hi Francis
At first i’ve added code block from documentation to Outgoing sync
//below section of for link sync and information to other jira
import com.atlassian.jira.component.ComponentAccessor
def jIssue = ComponentAccessor
.getIssueManager()
.getIssueObject(issue.key)
def ilm = ComponentAccessor.getIssueLinkManager()
def linkToMapFn = { ldir ->
{ l ->
[
"from": [
"id": l.sourceObject.id,
"key": l.sourceObject.key
],
"to": [
"id": l.destinationObject.id,
"key": l.destinationObject.key
],
"direction": ldir,
"linkType": (ldir == "relates to")? l.issueLinkType.outward : l.issueLinkType.inward,
"style": l.issueLinkType.style
]
}
}
replica.customKeys.issueLinks = [
"out": ilm
. getOutwardLinks(jIssue.id)
.collect(linkToMapFn("relates to")),
"in": ilm
. getInwardLinks(jIssue.id)
.collect(linkToMapFn("relates to"))
]
//for inwards and outward added currently used issue links
In cloud Jira to which synchronizing data added this part in incoming sync
// add the links information to the custom field
issue.customFields."Remote Linked issues".value = replica.issueLinks.toString()
// below are additioanl fields which collect data but they add exalated issue key and status
//issue.customFields."Remote Linked Key".value = replica.key
//issue.customFields."Remote Linked Status".value = replica.status.name
So at this moment, I have a second option to create a custom field, which would contain linked issue statuses, key and would have automated updates for linked issue changes.
Then create new sync for custom fields from Jira DC to Jira cloud
But I would greatly appreciate it if there could be a way without our developers coding custom field which would have such functionality.
Francis Martens (Exalate) commented on 10 September 2020
Line 2 in your incoming sync is wrong.
In the outgoing - you are storing the data into replica.customKeys.issueLinks
In the incoming - you are getting the data from replica.issueLinks - which is also a valid object.
Please rectify the incoming sync and inspect if the data you get is the data you expect by doing a
throw new Exception("...")
As explained in the Debugging Sync scripts on Exalate