1
0
-1

How can I get incident.caller_id = replica.reporter on both sides of the integration (Jira - ServiceNow)

    CommentAdd your comment...

    1 answer

    1.  
      2
      1
      0

      Hi!


      This can be achieved with the following scripts:


      Sync Reporter from Jira to Caller ID in ServiceNow:


      Outgoing Sync Jira:

      replica.reporter = issue.reporter


      Incoming Sync ServiceNow:

      incident.caller_id = nodeHelper.getUserByEmail(replica.reporter?.email)?.key


      Sync Caller ID from ServiceNow to Reporter on Jira:


      Outgoing Sync ServiceNow:

      if(!(incident.caller_id instanceof String)){
      replica.callerMail = nodeHelper.getTableByLink(incident.caller_id?.link)?.email
      }


      Incoming Sync Jira:

      issue.reporter = nodeHelper.getUserByEmail(replica.callerMail)


      Keep in mind that this will only work if the reporters have the same e-mail on both sides. 


      If the reporters have different e-mails on each side, you can use a mapping to map between users like so:


      Incoming Sync:

      def userMapping = ["snowuser@example.com":"jirauser@example.com"]
      issue.reporter = nodeHelper.getUserByEmail(userMapping[replica.callerMail])


      Another option if you don't want to map users would be to try to find a user with the same e-mail as the source side in the destination, and if it's not found, then set a default user:


      Incoming Sync:

      def defaultUser = nodeHelper.getUserByEmail("defaultuser@example.com")
      issue.reporter = nodeHelper.getUserByEmail(replica.callerMail) ?: defaultUser


      Thanks,


      André

        CommentAdd your comment...