Originally asked by Benjamin Kiene on 18 August 2021 (original question)
I’m trying to impersonate the comments with help of the commentHelper.mergeComments() function on the JIRA side as provided in the default incoming script
//Jira incoming sync script
/*
Comment Synchronization
Sync comments with the original author if the user exists in the local instance
Remove original Comments sync line if you are using this approach
*/
issue.comments = commentHelper.mergeComments(issue, replica){ it.executor = nodeHelper.getUserByEmail(it.author?.email) }
Unfortunately, I found that the remote replica (coming from a ServiceNow instance) doesn’t contain the email variable in the author array for one reason or another. (It seems like Exalate is not putting it in the replica when syncing out from ServiceNow, see example below)
//Remote replica example comment data
{
"id": "0608934d1b0d38d0555798ac0a4bcbc7",
"author": {
"key": "kieneb",
"active": false,
"displayName": "kieneb",
"username": "kieneb"
},
"body": "Comment Test 2",
"created": 1624877549000,
"internal": true,
"restrictSync": false
}
//ServiceNow outgoing sync script
replica.comments = incident.comments
I was wondering whether it is possible to do something like the below in the outgoing sync?
//ServiceNow outgoing sync script
commentHelper.mergeComments(replica, incident) { it.author.email = nodeHelper.getReference("user_table","username", it.author.username).email }
Or is there any other way to get Exalate to add the email of the comment author into the replica or is it ServiceNow that is determining what author details are saved in each comment and would need to be changed in the ServiceNow instance somewhere? If so, would you happen to know how and where it can be changed?
Comments:
Ariel Aguilar commented on 19 August 2021
Hi Ben,
You could try to do in Jira Incoming the following instead:
issue.comments = commentHelper.mergeComments(issue, replica){ it.executor = nodeHelper.getUserByUsername(replica.author?.username)}
Kind regards,
Ariel
Benjamin Kiene commented on 23 August 2021
Hi Ariel,
Thank you for your quick reply!
If I understand it correctly if I do it on the incoming sync the nodeHelper function queries the JIRA instance to get the user by username.
The problem with that is that the usernames in JIRA are not matching the usernames in SNOW, hence why we need to go through the email address (which do match).
But then Exalate is not putting the email address in the author section out of the box through the standard
replica.comments = incident.comments
instruction in the outgoing script in SNOW. That’s why I’m wondering whether I could customize it to include the email address in there as well.
I’m open to alternative solutions, but unless I misunderstand something your suggestion would not work, no?
Thank you for your support and checking again!
Best regards,
Ben
Ariel Aguilar commented on 23 August 2021
Hi Ben,
We have a way to extract the email from: incident.caller:
Outgoing Snow:
if(!(incident.caller_id instanceof String)){
replica.callerMail = nodeHelper.getTableByLink(incident.caller_id?.link)?.email
}
Incoming Jira:
issue.comments = commentHelper.mergeComments(issue, replica){ it.executor = nodeHelper.getUserByEmail(replica.callerMail)}
Let me know if this works for you.
Kind regards,
Ariel
Benjamin Kiene commented on 02 September 2021
Hi Ariel,
Thank you for your feedback!
Unfortunately, if I understand your suggested solution correctly, it would not help as all the comments would appear as being from the caller.
That’s why I was wondering about the possibility to save the email address with the author details of each comment as each comment might be from a different author (e.g. different support agents) and not from the caller.
Any further ideas are appreciated!
Best regards,
Benjamin
Benjamin Kiene commented on 08 September 2021
Hi Ariel Aguilar, Saskia,
Are there any further updates?
Any idea how the email could be saved with the author on the ServiceNow side, so that I can access it on the Jira side?
Thank you for your kind help!
Best regards,
Benjamin