# Jira \<-\> Zendesk - Visual version - Only send public replies from Jira

**URL:** <https://community.exalate.com/t/jira-zendesk-visual-version-only-send-public-replies-from-jira/4790>\
**Category:** General Questions\
**Tags:** exalate, zendesk, jira, migrated\_question\
**Created:** [November 4, 2024, 7:24am UTC](https://community.exalate.com/t/jira-zendesk-visual-version-only-send-public-replies-from-jira/4790 "2024-11-04T07:24:04Z")\
**Posts on this page:** 3\
**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:24am UTC](https://community.exalate.com/t/jira-zendesk-visual-version-only-send-public-replies-from-jira/4790/1 "2024-11-04T07:24:04Z")

</div>

_Originally asked by Svein Tvedt on 27 July 2021 [(original question)](https://oldcommunity.exalate.com/questions/30050267)_

* * *

Hi again 😄

I am not able to figure this one out and I hope you can help me out.

I am trying to update my Visual connection between Zendesk and Jira and the script that I created below based on the answer that you gave me in the last post I submitted.

What I am trying to accomplish now is that I only want public reply comments from Jira to be synchronized with Zendesk. Jira (Payments) to Zendesk (CS).

I have tried looking up the documentation, but it seemed to be geared towards Scripting connections as I am not getting that code to work. I tried what was posted here, but that’s not working for me: [Only sync internal comments](https://oldcommunity.exalate.com/display/exacom/questions/11338358/only-sync-internal-comments)_(old community)_ (doing it like this: `replica.comments = issue.comments.``findAll``{!it.internal}` which can be found here [https://docs.idalko.com/exalate/display/ED/How+to+synchronize+comments](https://docs.idalko.com/exalate/display/ED/How+to+synchronize+comments))

```auto
if (executionInstanceName == "Payments") {
    replica.comments = nodeHelper.getHtmlComments(issue)
    replica.comments = commentHelper.mergeComments(issue, replica,{
       comment ->
       comment.body =
          comment.author.displayName +
                  " commented: \n" +
          comment.body + "\n"
    }
)
}
if (executionInstanceName == "CS") {
    replica.comments = commentHelper.mergeComments(issue, replica, {
    comment ->
    comment.internal = true
    comment.body =
        comment.author.displayName +
                " commented: \n" +
        comment.body + "\n"
  }
)
}

```

Would you be able to take a look at this and help me out?

Thanks in advance!

* * *

#### Comments:

> **Ariel Aguilar commented on 28 July 2021**
>
> > Hi Svein,
> 
> For this case, this should work:
> 
> ```auto
> if (executionInstanceName == "JIRACLOUD") {
> def includeComments = commentHelper.mergeComments(issue, replica).collect{it}
> issue.comments = nodeHelper.toMarkDownComments(includeComments)
> }
> if (executionInstanceName == "ZD") {
> replica.comments = replica.comments.findAll{!it.internal}
> issue.comments = commentHelper.mergeComments(issue, replica, {
> comment ->
> comment.internal = true
> comment.body =
> comment.author.displayName +
> " commented: \n" +
> comment.body + "\n"
> }
> )
> }
> 
> ```
> 
> Let me know how it goes!
> 
> Kind regards,
> 
> Ariel

> **Chris Lord commented on 29 July 2021**
>
> > Hi Ariel Aguilar ,
> 
> Please note that I am following up as Svein is on leave.
> 
> I have implemented the following code.
> 
> ```auto
> if (executionInstanceName == "Payments") {
> def includeComments = commentHelper.mergeComments(issue, replica).collect{it}
> issue.comments = nodeHelper.toMarkDownComments(includeComments)
> }
> if (executionInstanceName == "CS") {
> replica.comments = replica.comments.findAll{!it.internal}
> issue.comments = commentHelper.mergeComments(issue, replica, {
> comment ->
> comment.internal = true
> comment.body =
> comment.author.displayName +
> " commented: \n" +
> comment.body + "\n"
> }
> )
> }
> 
> ```
> 
> However I am still receiving an internal comment on Zendesk when an internal comment is left by an agent on Jira.
> 
> For clarity, Payments is Jira and Zendesk is CS.
> 
> Please let me know if you see anything wrong.
> 
> Thanks,

> **Ariel Aguilar commented on 29 July 2021**
>
> > Hi there,
> 
> If you try this:
> 
> ```auto
> if (executionInstanceName == "Payments") {
> def includeComments = commentHelper.mergeComments(issue, replica).collect{it}
> issue.comments = nodeHelper.toMarkDownComments(includeComments)
> issue.comments = issue.comments.findAll{!it.internal}
> }
> if (executionInstanceName == "CS") {
> issue.comments = commentHelper.mergeComments(issue, replica, {
> comment ->
> comment.internal = true
> comment.body =
> comment.author.displayName +
> " commented: \n" +
> comment.body + "\n"
> }
> )
> }
> 
> ```
> 
> Let me know if only public comments are sent now.
> 
> Kind regards,
> 
> Ariel

> **Chris Lord commented on 30 July 2021**
>
> > Hi Ariel,
> 
> Thanks for the help.
> 
> I have implemented the recent script, clicked on the save button and published changes.
> 
> ![](https://dub1.discourse-cdn.com/flex018/download/attachments/30050267/image2021-7-30_12-32-30.png?version=1&modificationDate=1627641150759&api=v2)
> 
> I then made a public and internal comment on Jira as per the screenshot below.
> 
> ![](https://dub1.discourse-cdn.com/flex018/download/attachments/30050267/image2021-7-30_12-33-31.png?version=1&modificationDate=1627641212336&api=v2)
> 
> When checking Zendesk it still receiving the internal comment from Jira and sending it as an internal comment on Zendesk.
> 
> ![](https://dub1.discourse-cdn.com/flex018/download/attachments/30050267/image2021-7-30_12-34-56.png?version=1&modificationDate=1627641296727&api=v2)
> 
> Can you see anything wrong with here or have any suggestions on the scripting I can try out next.
> 
> Appreciate your help on this.
> 
> Thanks

> **Svein Tvedt commented on 03 August 2021**
>
> > Hi Ariel Aguilar
> 
> Just bumping the thread, thanks

---

<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:24am UTC](https://community.exalate.com/t/jira-zendesk-visual-version-only-send-public-replies-from-jira/4790/2 "2024-11-04T07:24:05Z")

</div>

_Answer by Ariel Aguilar on 04 August 2021_

Hi Svein,

Sorry if I took some time, it seems we were conflicting with one of the limitations when using Visual Connections and actually if you are going to have this kind of configurations it is recommended to go to Script based connection, however I found a workaround for the original topic:

```auto
if (executionInstanceName == "Payments") {
    def includeComments = commentHelper.mergeComments(issue, replica).collect{it}
    issue.comments = nodeHelper.toMarkDownComments(includeComments)
}

if (executionInstanceName == "CS") {
    replica.getClass().fields
    def locked = replica.getClass().declaredFields.find{it.name == "_locked"}
    locked.setAccessible(true)
    locked.set(replica, false)
    replica.addedComments = replica.addedComments.findAll{!it.internal}
    issue.comments = commentHelper.mergeComments(issue, replica, {
    comment ->
    comment.internal = true
    comment.body =
        comment.author.displayName +
                " commented: \n" +
        comment.body + "\n"
  }
)
}

```

Let me know if this works now.

Kind regards,

Ariel

* * *

#### Comments:

> **Svein Tvedt commented on 05 August 2021**
>
> > Hi Ariel Aguilar
> 
> This worked perfectly, thanks so much, we will check out script based connections in the future _(old community)_
> 
> BR,  
> Svein Tvedt

---

<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:24am UTC](https://community.exalate.com/t/jira-zendesk-visual-version-only-send-public-replies-from-jira/4790/3 "2024-11-06T07:24:28Z")

</div>

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