You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
Sync a Jira issue Field as Work Note in ServiceNow: an Advanced Use Case
We get a lot of customer requests to integrate Jira and ServiceNow at Exalate. And we come across a lot of interesting use cases in the process. I am sharing one here.
A Jira issue is synced with a ServiceNow incident.
2 advanced requirements are:
When a comment is added to a synced issue in Jira, then it must appear as a Work note (or an internal note) on the ServiceNow side.
If any change is made to a particular field on the Jira issue, that change must be logged as a private Work note on the ServiceNow side.
Note: We are syncing ‘Summary’ from Jira as a Work Note in ServiceNow for this example. But it can very well be any other field.
Syncing summary and description in Jira as a summary and short description in ServiceNow is simple and can be implemented out-of-the-box.
But the real challenge lies in:
Exalate works as a bidirectional integration solution for Jira, Zendesk, ServiceNow, Azure DevOps, Salesforce, and the like. We can implement the above use case using the Exalate API. It is made possible with an in-built Groovy scripting engine that allows you to implement complex use cases.
So you can configure incoming and outgoing information independently via processors present on both sides of the integration.
Exalate has 2 modes that serve different functions.
The Basic mode is for syncing only the issue type, description, summary, attachments, and comments. It cannot be configured and comes with a Free Plan.
The Script mode is where most of the complex processing happens. This mode consists of Groovy-based scripts called Sync rules that control information flow at both ends independently.
For this use case, we create a Script mode connection.
At the Jira end, the outgoing sync decides what information will go out from Jira to ServiceNow and the incoming sync decides what information will be received from ServiceNow. This is the same on the ServiceNow side, only the syncs are reversed.
We can modify these syncs under the “Rules” tab.
Note: The “Triggers” tab is used to automatically start syncing information when certain conditions are met.
The out-of-the-box configuration on the Jira side remains unchanged since there is no additional tweaking required there.
The changes made from the Jira end need to be reflected differently on the ServiceNow side, so we need to modify its “Incoming sync”.
Let us see how these requirements will be met one by one.
Here, the line that deals with comments on the ServiceNow side is: entity. comments += replica.addedComments
This line simply syncs the comments from Jira to ServiceNow as it is. We want to modify this behavior. So we comment it out.
And add this line.
We use the mergeComments method of the commentHelper class that Exalate provides to merge the comments on the ServiceNow side. The thing that does the magic is it.internal=true at the end. This allows the comments from the Jira side to be treated as internal comments on the ServiceNow side.
The second part is slightly different than just adding a line of code. Here, during the firstSync (the first if condition in the above code block) we need the summary of the issue to be reflected under a short description in ServiceNow.
So we put entity.short_description = replica.summary under the firstSync if condition.
Now upon subsequent syncs, we do not want the short description to be updated. So we remove that line.
To populate the work notes from the Jira summary there on, we add the code shown in the image below.
The main object of interest here is “previous”. It allows us to capture the previous values of the sync. So if the previous summary is different from the current one coming in from Jira then add the necessary text you need to be followed by the actual new summary.
We start by creating an issue in Jira and syncing it over to ServiceNow.
Summary, short description, and other required fields have been synced.
Leave a comment in Jira and see the comment reflected on the other side as a Work note.
Also, change the summary on the Jira issue and see it reflected on the ServiceNow side as a Work note.
There is a lot you can already plan to do using Exalate. Its advanced yet intuitive scripting engine allows you to accommodate a variety of use cases. The helper classes it provides, with a bulk load of methods, make your task a lot easier.
So give it a try if you still haven't, or book a demo with our experts to experience a smooth integration.