1 answer
- 10-1
//This is the definition in the Jira instance Incoming sync connection
def remoteStatusName = replica.status.name
def statusMap = ["Open":"Open", "Work in Progress":"In Progress",
"Pending":"Needs Info", "Closed Complete":"Resolved",
"Resolved": "Resolved" , "In Progress":"In Progress","New":"Open", "On Hold":"Needs Info", "Canceled":"Closed", "Closed":"Closed"]if (replica.status == null ||
replica.status.name == null ||
statusMap.get(replica.status.name) == null) {
issue.comments = commentHelper.addComment("Remote status is unknown or cannot be mapped - can't handle it", issue.comments)
}
else if (replica.status.name == "Resolved" ){
issue.resolution = nodeHelper.getResolution("Fixed")
}
else if (replica.status.name == "Closed" ){
issue.resolution = nodeHelper.getResolution("Done")
}
else {
issue.setStatus(statusMap[replica.status.name])
}if (replica.resolution == null) {
// if the remote issue is not resolved
issue.resolution = null
}
if (replica.resolution != null) {
// the remote issue is resolved, but the local isn't - look up the correct local resolution object.
def resolutionMap = [
"Solved" : "Done",
"Closed/Resolved by Requester" : "Won't Do",
"Not Solved" : "Won't Fix"
]
// use 'done' as resolution if the remote resolution is not found
def targetResolutionName = resolutionMap[replica.resolution.name] ?: "Done"
// nodeHelper.getResolution looks up the local resolution object based on the provided name
issue.resolution = nodeHelper.getResolution(targetResolutionName)
}
Add your comment...
To sync the resolution from Jira to ServiceNow, I have written below code in the incoming sync of SNOW. It was working before. However, when I retested, it gave me error in the line #9 - Cannot get property name on null object.
Hi Archita,
Is there a chance the issue that caused the error, did not have any value matching the resolutionMap? Then if the value is coming "null" you can try:
Let me know if this works for you.
Kind regards,
Ariel
Hi Ariel,
Thanks for your response. I added your changes and now getting below error.
'Script cannot be saved. Details: startup failed: Script408.groovy: 34: unexpected token: ? @ line 34, column 70. onMap[replica.resolution?.name?] ?: "Sol ^ 1 error '
Regards,
Archita
Ariel,
I removed the extra question mark after name and it worked.