1
0
-1

Hi again (smile)


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 (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)


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!

  1. Ariel Aguilar

    Hi Svein,

    For this case, this should work:

    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


  2. Chris Lord

    Hi Ariel Aguilar ,


    Please note that I am following up as Svein is on leave.


    I have implemented the following code.


    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,

  3. Ariel Aguilar

    Hi there,

    If you try this:

    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

  4. Chris Lord

    Hi Ariel,


    Thanks for the help.


    I have implemented the recent script, clicked on the save button and published changes.


    I then made a public and internal comment on Jira as per the screenshot below.



    When checking Zendesk it still receiving the internal comment from Jira and sending it as an internal comment on Zendesk.


    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


  5. Svein Tvedt

    Hi Ariel Aguilar 

    Just bumping the thread, thanks


CommentAdd your comment...

1 answer

  1.  
    1
    0
    -1

    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:


    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

    1. Svein Tvedt

      Hi Ariel Aguilar


      This worked perfectly, thanks so much, we will check out script based connections in the future (smile)


      BR,
      Svein Tvedt



    CommentAdd your comment...