Can I sync Jira assignee to ServiceNow resolved_by?

I have Jira assignee syncing to ServiceNow assigned_to with this code:
entity.assigned_to = replica.assignee?.email

What I am trying to do is: When the Jira card status is changed to ‘Done’ the ServiceNow incident should be changed to ‘Resolved’ with a resolution note and the resolved_by user should be the same as the Jira assignee. The ServiceNow status and resolution note are working fine but the resolved_by user is being set to ‘Exalate Integration’.

This code is in SN incoming script:
if(replica.status?.name == “Done”){
entity.state = “Resolved”
entity.close_code =“Solved (Work Around)”
def defaultResolution = "Done on Jira cloud. No resolution entered. Card " + replica.key
def Resolution = replica.customFields?.“Resolution Notes”?.value ?: defaultResolution
entity.close_notes = Resolution // replica.customFields?.“Resolution Notes”?.value

    //Nov 2024 MVanOstrand - added resolved_by to sync
    entity.resolved_by = replica.resolved_by?.email

This code is in Jira outgoing script:
replica.assignee = issue.assignee
replica.resolved_by = issue.assignee

I have capture the local and remote replica data and will attach if I can figure out how.

Hi @Melinda_VanOstrand
I am not able to see the local and remote replica.
Is it possible to paste necessary portion of replica if it is not possible to attach it?
Thanks,
Sonal

@Sonal_Otwani I just now saw I can attach here.

…but only an image. I replied to the email, let me know if you get it.

Melinda VanOstrand
(806) 786-8233

upcoming out of office:
— every Wednesday 8:00 - noon

(Attachment Resolved_by issue.docx is missing)

Note: I had to add { before my email address so this app does not see it as a link, the { is not actually in the replica data.

Jira local replica:
{
“version”: {
“major”: 1,
“minor”: 14,
“patch”: 0
},
“hubIssue”: {
“resolved_by”: {
“key”: “5e14b56061d95d0d9aa6491e”,
“active”: true,
“email”: “{mvanostrand@unitedtexas.com”,
“displayName”: “Melinda VanOstrand”
},
“voters”: ,
“project”: {
“idStr”: “11598”,
“key”: “SER”,
“name”: “ServiceNow”
},
“fixVersions”: ,
“resolution”: {
“id”: “10000”,
“name”: “Done”,
“description”: “Work has been completed on this issue.”
},
“internalMap”: {
“resolved_by”: {
“key”: “5e14b56061d95d0d9aa6491e”,
“active”: true,
“email”: “{mvanostrand@unitedtexas.com”,
“displayName”: “Melinda VanOstrand”
}
},
“priority”: {
“id”: “4”,
“name”: “Low”
},
“labels”: ,
“customKeys”: {},
“issueType”: {
“id”: “10004”,
“name”: “Bug”
},
“assignee”: {
“key”: “5e14b56061d95d0d9aa6491e”,
“active”: true,
“email”: “{mvanostrand@unitedtexas.com”,
“displayName”: “Melinda VanOstrand”
},

SN remote replica:
{
“version”: {
“major”: 1,
“minor”: 14,
“patch”: 0
},
“hubIssue”: {
“resolved_by”: {
“key”: “5e14b56061d95d0d9aa6491e”,
“active”: true,
“email”: “{mvanostrand@unitedtexas.com”,
“displayName”: “Melinda VanOstrand”
},
“voters”: ,
“project”: {
“idStr”: “11598”,
“key”: “SER”,
“name”: “ServiceNow”
},
“fixVersions”: ,
“resolution”: {
“id”: “10000”,
“name”: “Done”,
“description”: “Work has been completed on this issue.”
},
“internalMap”: {
“resolved_by”: {
“key”: “5e14b56061d95d0d9aa6491e”,
“active”: true,
“email”: “{mvanostrand@unitedtexas.com”,
“displayName”: “Melinda VanOstrand”
}
},
“priority”: {
“id”: “4”,
“name”: “Low”
},
“labels”: ,
“customKeys”: {},
“issueType”: {
“id”: “10004”,
“name”: “Bug”
},
“assignee”: {
“key”: “5e14b56061d95d0d9aa6491e”,
“active”: true,
“email”: “{mvanostrand@unitedtexas.com”,
“displayName”: “Melinda VanOstrand”
},

Hi Melinda,

A very warm welcome to the community! And thanks for flagging the upload issue - it should be fixed now!

The remote replica clearly shows that you are indeed receiving the correct information from the Jira side. What needs to happen now is to make the assignment happen in SNOW. The piece that you were missing was calling a helper method to find the correct user e.g.:
entity.assigned_to = nodeHelper.getUserByEmail(replica.assignee?.email)?.key

Give this a try please and let me know how it goes.

Thanks
Majid

p.s.: This might be a great question for the in-product AI Assist as well.

Thanks @Majid ! Your suggestion fixed half my issue.
I changed my code for both entity.assigned_to and entity.resolved_by to use the nodeHelper.
SNOW assigned_to is not correctly updated but resolved_by is still ‘Exalate Integration’.

Hi @Melinda_VanOstrand
Can you please try this:

def remoteEmail = replica. assignee?.email
if(remoteEmail){
entity.assigned_to = nodeHelper.getReference(“sys_user”, “email”, remoteEmail)?.sys_id
entity.resolved_by = nodeHelper.getReference(“sys_user”, “email”, remoteEmail)?.sys_id

}

@Sonal_Otwani the script will not accept “sys_user”. The groovy error is ‘unexpected character’.

Hi @Melinda_VanOstrand
Yes try to remove " and add again , this is because of double quote character. Please remove and then re-add

try to copy this:>

        def remoteEmail = replica. assignee?.email
    if(remoteEmail){
    entity.assigned_to = nodeHelper.getReference("sys_user", "email", remoteEmail)?.sys_id
    entity.resolved_by = nodeHelper.getReference("sys_user", "email", remoteEmail)?.sys_id

    }

Resolved_by is still being set to Exalate. I am going to ask our SNOW administrator to take another look at the business rules.

Thanks @Melinda_VanOstrand for the update!
Let’s first get business rule details from ServiceNow admin then we can schedule a call to debug this further.

Hi @Melinda_VanOstrand
Can you please update us whether the provided solution did work ?
Waiting for your confirmation !
Thanks,
Sonal

The provided solution did not work. SNOW resolved_by is still being set to ‘Exalate Integration’.