# Resolution sync issue - Cannot get property name on null object

**URL:** https://community.exalate.com/t/resolution-sync-issue-cannot-get-property-name-on-null-object/4868
**Category:** General Questions
**Tags:** usecase, migrated\_question
**Created:** [November 4, 2024, 7:28am UTC](https://community.exalate.com/t/resolution-sync-issue-cannot-get-property-name-on-null-object/4868 "2024-11-04T07:28:37Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![xl8bot](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/xl8bot/32/324_2.png) [@xl8bot](https://community.exalate.com/u/xl8bot)
#### Post date: [November 4, 2024, 7:28am UTC](https://community.exalate.com/t/resolution-sync-issue-cannot-get-property-name-on-null-object/4868/1 "2024-11-04T07:28:37Z")

</div>

_Originally asked by Archita Gupta on 24 September 2021 [(original question)](https://oldcommunity.exalate.com/questions/37552696)_

* * *

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.

```auto
if(entity.tableName == "incident") {
  entity.close_notes = "Resolved in Jira"
    entity.close_code = replica.resolution
    def resolutionMap = [
        "Done" : "Solved",
        "Won't Do" : "Closed/Resolved by Requester",
        "Known Error" : "Not Solved"
   ]
    def targetResolutionName = resolutionMap[replica.resolution.name] ?: "Solved" //issue in this line 
    entity.close_code = resolutionMap[targetResolutionName] ?: targetResolutionName //close_code is name of the field (Resolution code) in SNOW.
   entity.save
}

```

* * *

#### Comments:

> **Ariel Aguilar commented on 24 September 2021**
>
> > 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:
> 
> ```auto
> if(entity.tableName == "incident") {
> entity.close_notes = "Resolved in Jira"
> entity.close_code = replica.resolution
> def resolutionMap = [
> "Done" : "Solved",
> "Won't Do" : "Closed/Resolved by Requester",
> "Known Error" : "Not Solved"
> ]
> def targetResolutionName = resolutionMap[replica.resolution?.name?] ?: "Solved" // ***this was the only line modified***
> entity.close_code = resolutionMap[targetResolutionName] ?: targetResolutionName //close_code is name of the field (Resolution code) in SNOW.
> entity.save
> }
> 
> ```
> 
> Let me know if this works for you.
> 
> Kind regards,
> 
> Ariel

> **Archita Gupta commented on 24 September 2021**
>
> > 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

> **Archita Gupta commented on 28 September 2021**
>
> > Ariel,
> 
> I removed the extra question mark after name and it worked.
> 
> ```auto
> def targetResolutionName = resolutionMap[replica.resolution?.name] ?: "Solved"   
>   
> However, this is my outgoing sync and is throwing error which is why   
> state in Jira is not changing to Resolved and resolution code is not syncing  
> Can you help?  
> replica.resolution = entity.close_code  
> close_code is the internal name for Resolution code.
> 
> ```

---

<div class="post-metadata">

### Author: ![xl8bot](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/xl8bot/32/324_2.png) [@xl8bot](https://community.exalate.com/u/xl8bot)
#### Post date: [November 4, 2024, 7:28am UTC](https://community.exalate.com/t/resolution-sync-issue-cannot-get-property-name-on-null-object/4868/2 "2024-11-04T07:28:38Z")

</div>

_Answer by Pinky Kohsuwan on 24 September 2021_

**//This is the definition in the Jira instance Incoming sync connection**

def remoteStatusName = [replica.status.name](http://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](http://replica.status.name) == null ||  
statusMap.get([replica.status.name](http://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](http://replica.status.name) == “Resolved” ){  
issue.resolution = nodeHelper.getResolution(“Fixed”)  
}  
else if ([replica.status.name](http://replica.status.name) == “Closed” ){  
issue.resolution = nodeHelper.getResolution(“Done”)  
}  
else {  
issue.setStatus(statusMap[[replica.status.name](http://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](http://replica.resolution.name)] ?: “Done”

// nodeHelper.getResolution looks up the local resolution object based on the provided name  
issue.resolution = nodeHelper.getResolution(targetResolutionName)  
}

* * *
