# Post comment with the ticket number after initial sync

**URL:** <https://community.exalate.com/t/post-comment-with-the-ticket-number-after-initial-sync/4527>\
**Category:** General Questions\
**Tags:** jira-service-desk, migrated\_question\
**Created:** [November 4, 2024, 7:04am UTC](https://community.exalate.com/t/post-comment-with-the-ticket-number-after-initial-sync/4527 "2024-11-04T07:04:13Z")\
**Posts on this page:** 5\
**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:04am UTC](https://community.exalate.com/t/post-comment-with-the-ticket-number-after-initial-sync/4527/1 "2024-11-04T07:04:13Z")

</div>

_Originally asked by Adriano Mazi on 29 December 2020 [(original question)](https://oldcommunity.exalate.com/questions/20123785)_

* * *

I have a connection between Jira Server and Jira Service Desk and I’m trying to create a configuration that will post a comment (with the ticket number) on Jira Service Desk after the ticket on Jira Server has been opened.

I’m syncing the statuses between the tickets and added the comment information inside this part but it’s not working automatically, it only worked after I posted a comment on my ticket on Jira Server.

if (issue.type == nodeHelper.getIssueType(“Incident”)) {  
def statusOpenMap = [“Open”:“Acknowledged”, “To Do”:“Acknowledged”, “In Progress”:“Acknowledged”] // [“remote status name”: “local status name”]  
def remoteOpenStatusName = [replica.status.name](http://replica.status.name)  
if ([replica.status.name](http://replica.status.name) == “Open” || [replica.status.name](http://replica.status.name) == “To Do”) {  
String syncissue\_open = “Development ticket ‘${replica.key}’ has been opened”  
issue.comments = commentHelper.addComment(issue.comments){ comment -\>  
comment.body = syncissue\_open  
comment.restrictSync = true  
comment.internal = false  
}  
issue.setStatus(statusOpenMap[remoteOpenStatusName] ?: remoteOpenStatusName)  
}

* * *

---

<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:04am UTC](https://community.exalate.com/t/post-comment-with-the-ticket-number-after-initial-sync/4527/2 "2024-11-04T07:04:14Z")

</div>

_Answer by Adriano Mazi on 08 January 2021_

I was able to find a configuration that works by creating a custom field called “Development Ticket” that will receive the ticket number and post a public comment afterwards.

if (!firstSync && issue.customFields.“Development Ticket”.value == null) {

// Post the ticket number in the custom field

issue.customFields.“Development Ticket”.value = replica.key

// Add a public comment that won’t be sync back

String syncissue\_open = “Development ticket \*${replica.key}\* has been opened”

issue.comments = commentHelper.addComment(issue.comments){ comment -\>

comment.body = syncissue\_open

comment.restrictSync = true

comment.internal = false

}

}

* * *

---

<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:04am UTC](https://community.exalate.com/t/post-comment-with-the-ticket-number-after-initial-sync/4527/3 "2024-11-04T07:04:15Z")

</div>

_Answer by Francis Martens (Exalate) on 08 January 2021_

The way that Exalate works is that the incoming sync processor will be applied when receiving a message from the other side

The fact that it works when you make an update on the Jira Server is an indication that the incoming sync is behaving correctly.

So you need to find a way to trigger a message when the Jira Server issue is opened.  
This can be done automatically using the [SyncBackAfterProcessing](https://docs.idalko.com/exalate/display/ED/syncBackAfterProcessing) approach.

On the Jira Server - in the incoming sync add something like

```auto
if (firstSync) {
   ...
   syncHelper.syncBackAfterProcessing()
}

```

Exalate will then trigger a sync back once that the message has finished processing …

* * *

---

<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:04am UTC](https://community.exalate.com/t/post-comment-with-the-ticket-number-after-initial-sync/4527/4 "2024-11-04T07:04:16Z")

</div>

_Answer by Adriano Mazi on 08 January 2021_

I’ve added this configuration and tested several other possibilities, but still wasn’t able to find a configuration that work. If I add the configuration inside the “firstSync” section, it does not work. If I add outside, I will post duplicate comments.

* * *

---

<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 6, 2024, 7:04am UTC](https://community.exalate.com/t/post-comment-with-the-ticket-number-after-initial-sync/4527/5 "2024-11-06T07:04:34Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
