1
0
-1

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?

  1. Ariel Aguilar

    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

  2. Benjamin Kiene

    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

  3. Ariel Aguilar

    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


  4. Benjamin Kiene

    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

  5. Benjamin Kiene

    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

CommentAdd your comment...

1 answer

  1.  
    2
    1
    0

    Hi, Benjamin Kiene excellent question! I think I might have the solution.
    What I did is on the outgoing sync of SNOW I ask for snow for the whole user object of the author for every comment. Then I add the email to the comment author. The code you can find here.

    replica.comments       = entity.comments
    for(comment in replica.comments){
            def user = nodeHelper.getUserByUsername(comment.author.displayName)
            comment.author.email = user.email
        }
        
    }

    Which should result in:



    Please let me know if it does or doesn't work. 
    Kind regards,
    Michiel (smile) 

    1. Benjamin Kiene

      Hi Michiel Meurs,


      Thank you very much for your solution and I'm very sorry for the delay in my reply.


      I've tested and used your suggested solution in my projects and it made everything work flawlessly and as expected now, thank you so much! (smile)


      I really appreciate your quick and expert support despite my delayed reply!


      Kind regards,

      Benjamin

    CommentAdd your comment...