# ServiceNow Incident to Jira Bug

**URL:** <https://community.exalate.com/t/servicenow-incident-to-jira-bug/4768>\
**Category:** General Questions\
**Tags:** servicenow-jira, migrated\_question\
**Created:** [November 4, 2024, 7:22am UTC](https://community.exalate.com/t/servicenow-incident-to-jira-bug/4768 "2024-11-04T07:22:33Z")\
**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:22am UTC](https://community.exalate.com/t/servicenow-incident-to-jira-bug/4768/1 "2024-11-04T07:22:33Z")

</div>

_Originally asked by Jose Lobo on 08 July 2021 [(original question)](https://oldcommunity.exalate.com/questions/30049289)_

* * *

We are trying to configure the logic so a ServiceNow incident creates a Jira Bug and a ServiceNow agile/story ticket creates a Jira Story.

We’d also like to do the reverse. We’ve tried a variety of combinations, but can’t quite get it right.

* * *

---

<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:22am UTC](https://community.exalate.com/t/servicenow-incident-to-jira-bug/4768/2 "2024-11-04T07:22:34Z")

</div>

_Answer by Serhiy Onyshchenko on 08 July 2021_

Hello, Jose Lobo , thanks for asking on community!  
It’s basically a combination of these guides:

- [https://docs.idalko.com/exalate/x/CgDuAg](https://docs.idalko.com/exalate/x/CgDuAg)
- and [https://docs.idalko.com/exalate/x/6QF1Aw](https://docs.idalko.com/exalate/x/6QF1Aw)

(Please note, that this is a wide table)

| Script | SNOW | Jira |
| --- | --- | --- |
| ​Outgoing sync | `replica.summary = entity.short_description replica.description = entity.description replica.comments = entity.comments replica.attachments = entity.attachments replica.entityType = entityType replica.key = entity.key` ​ | `replica.key = issue.key replica.type = issue.type replica.assignee = issue.assignee replica.reporter = issue.reporter replica.summary = issue.summary replica.description = issue.description replica.labels = issue.labels replica.comments = issue.comments replica.resolution = issue.resolution replica.status = issue.status replica.parentId = issue.parentId replica.priority = issue.priority replica.attachments = issue.attachments replica.project = issue.project //Comment these lines out if you are interested in sending the full list of versions and components of the source project. replica.project.versions = [] replica.project.components = []` ​ |
| Incoming sync | `if(replica.type.name == "Bug") { //if the received issue typeName is Bug create Incident on ServiceNow if(firstSync) { incident.correlation_id = replica.key } incident.short_description = replica.summary incident.description = replica.description incident.comments += replica.addedComments incident.attachments += replica.addedAttachments } else if (replica.type.name == "Story") { if(firstSync) { story.correlation_id = replica.key } story.short_description = replica.summary story.description = replica.description story.comments += replica.addedComments story.attachments += replica.addedAttachments } ` | `if(firstSync){ if ("story".equalsIgnoreCase(replica.entityType)) { issue.typeName = "Story" } else if ("incident".equalsIgnoreCase(replica.entityType)) { issue.typeName = "Bug" } else { // Don't sync anything but stories and bugs return } // use your project instead issue.projectKey = "SCRM" } issue.summary = replica.summary issue.description = replica.description issue.comments = commentHelper.mergeComments(issue, replica) issue.attachments = attachmentHelper.mergeAttachments(issue, replica) issue.labels = replica.labels /* User Synchronization (Assignee/Reporter) Set a Reporter/Assignee from the source side, if the user can't be found set a default user You can use this approach for custom fields of type User def defaultUser = nodeHelper.getUserByEmail("default@idalko.com") issue.reporter = nodeHelper.getUserByEmail(replica.reporter?.email) ?: defaultUser issue.assignee = nodeHelper.getUserByEmail(replica.assignee?.email) ?: defaultUser */ /* 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) } */ /* Status Synchronization Sync status according to the mapping [remote issue status: local issue status] If statuses are the same on both sides don't include them in the mapping def statusMapping = ["Open":"New", "To Do":"Backlog"] def remoteStatusName = replica.status.name issue.setStatus(statusMapping[remoteStatusName] ?: remoteStatusName) */ /* Custom Fields This line will sync Text, Option(s), Number, Date, Organization, and Labels CFs For other types of CF check documentation issue.customFields."CF Name".value = replica.customFields."CF Name".value */ ` |

Let me know how it goes,  
Regards, Serhiy.

* * *
