Hi Jillani,
Sure, here is the script:
Outgoing:
// Jira issues are now work items. The term “issues” in the code below works despite this change.
replica.key = issue.key
replica.type = issue.type
replica.assignee = issue.assignee
replica.reporter = issue.reporter
replica.summary = issue.summary
replica.description = issue.description
replica.labels = issue.labels
replica.comments = issue.comments.findAll { it.internal }
replica.resolution = issue.resolution
replica.status = issue.status
replica.parentId = issue.parentId
replica.priority = issue.priority
replica.attachments = issue.attachments
replica.project = issue.project
/*
Uncomment these lines if you want to send the full list of versions and components of the source project.
replica.project.versions =
replica.project.components =
*/
/*
Custom Fields (CF)
How to send any field value from the source side to the destination side.
1/ Add the value to the replica object using the Display Name of the specific field.
2/ Uncomment this next statement out and change accordingly:
replica.customFields.“CF Name” = issue.customFields.“CF Name”
*/
// Exalate API Reference Documentation:
Incoming:
if (firstSync) {
issue.projectKey = “CS”
}
issue.type = nodeHelper.getIssueType(replica.type?.name, issue.projectKey) ?: nodeHelper.getIssueType(“Task”, issue.projectKey)
issue.summary = replica.summary
issue.description = replica.description
// Merge comments and set all as internal
issue.comments = commentHelper.mergeComments(issue, replica) { it.internal = true; it }
issue.attachments = attachmentHelper.mergeAttachments(issue, replica)
issue.labels = replica.labels
/*
Custom Fields (CF)
To add incoming values to a Jira custom field, follow these steps:
1/ Find the Display Name of the CF. Note: If you have multiple custom fields with the same name,
then you can sync it using the custom field ID instead of its name. Know more about the steps here:
2/ Check how the value is coming over from the source side, by checking the “Entity Sync Status”
of an issue in sync and then selecting the “Show Remote Replica”.
3/ Add it all together like this:
issue.customFields.“CF Name”.value = replica.customFields.“CF Name”.value
*/
/*
Status Synchronization
For Status sync, we map the source status, to the destination status with a hash map.
The syntax is as follows:
def statusMap = [
“remote status name”: “local status name”
]
Go to Entity Sync Status, put in the entity key, and it will show you where to find the remote replica
by clicking on Show remote replica.
def statusMap = [
“New” : “Open”,
“Done” : “Resolved”
]
def remoteStatusName = replica.status.name
issue.setStatus(statusMap[remoteStatusName] ?: “Add a default status in these double quotes”)
*/
/*
User Synchronization (Assignee/Reporter)
Set a Reporter/Assignee from the source side. If the user can’t be found, set a default user.
You can also use this approach for custom fields of the type User
def defaultUser = nodeHelper.getUserByEmail(“default@exalate.com”)
issue.reporter = nodeHelper.getUserByEmail(replica.reporter?.email) ?: defaultUser
issue.assignee = nodeHelper.getUserByEmail(replica.assignee?.email) ?: defaultUser
*/
/*
Comment Synchronization
Impersonate comments with the original author. The sync will work if the user already exists
in the local instance.
Note: Don’t forget to remove the original comments sync line if you are using this approach.
issue.comments = commentHelper.mergeComments(issue, replica) {
it.executor = nodeHelper.getUserByEmail(it.author?.email)
}
*/
// Exalate API Reference Documentation:
Thanks