Answer by Howard Kenny on 29 August 2019
Hi,
I had a challenge in a similar scenario because the custom fields names were the same on both sides, but the options were different. I had to use ids instead of custom field names.
Below is along the lines of what I had to do. Please note that the ‘L’ is not a typo (at the end of “insert id of custom field on Destination side”)
I’m not an expert, so apologies if this wastes your time!
def typeOfSupport = [
"Project Configuration" : "Project Configuration",
"User Management" : "User Management"
]
// type of support sync: lookup the source type of support and set on the destination side
def SourceSupport = (replica.customFields."Type of Support"?.value?.value) as String
def desiredTypeofSupport = typeOfSupport[SourceSupport]
if (!desiredTypeofSupport) { return }
issue.customFields."insert id of custom field on Destination side".value = nodeHelper.getOption(issue, insert id of custom field on Destination sideL, desiredTeam)
Comments:
Juan Grases commented on 29 August 2019
Nice answer, I wanted to make a small fix:
issue.customFields."insert id of custom field on Destination side".value = nodeHelper.getOption(issue, insert id of custom field on Destination sideL, desiredTeam)
Should actually be:
issue.customFields."insert id of custom field on Local side".value = nodeHelper.getOption(issue, insert id of custom field on Local sideL, desiredTeam)
Also I wanted to add, that in case that option values are the same on both sides you can simplify the approach by doing:
def SourceSupport = replica.customFields."Type of Support"?.value?.value
def localSourceSupport = nodeHelper.getOption(issue, insert id of custom field on Local sideL, SourceSupport)
issue.customFields."insert id of custom field on Local side".value = localSourceSupport
Howard Kenny commented on 29 August 2019
So close!