1
0
-1

I want to sync a custom field in jira to public reply in zendesk, ie. any time custom field is editing a new public reply is created in zendesk. Note: I still want all other comments in JIRA to be added as internal notes in zendesk. The custom field in JIRA is called "External Notification"


Here is what I have so far and it is working to add internal comments in Zendesk but not public replies.

Zendesk Incoming Sync:

issue.comments = commentHelper.mergeComments(issue, replica, {it.internal = true; it})
if(replica.customFields."Test Field"?.value) { 
	issue.comments = commentHelper.addComment(replica.customFields."Test Field".value, true, issue.comments) 
}


JIRA Outgoing Sync:

replica.comments = issue.comments
replica.customFields."Test Field" = issue.customFields."External Notification" 
    CommentAdd your comment...

    1 answer

    1.  
      2
      1
      0

      Hi!

      That code should be adding a comment for every sync zendesk received where the CF Test Field value is set (not only the update that set it). So probably that's not what you want. Still is possible to solve your use case with:


      def testFieldV = replica.customFields."Test Field"?.value
      if(testFieldV){   
      if(firstSync || testFieldV != previous.customFields."Test Field"?.value)      
      issue.comments = commentHelper.addComment(issue.comments){comment ->
         comment.internal = false
         comment.body = testFieldV
        }
      }
      1. Spencer Johnson

        Juan Grases  Thanks for the info! I tried what you suggested and its not adding a comment so I modified it to 

        def testFieldV = replica.customFields."Test Field"?.value
        if(testFieldV) {   
            if(firstSync || testFieldV != previous.customFields."Test Field"?.value)  {    
                commentHelper.addComment(issue.comments){comment ->
                                                        comment.internal = false
                                                        comment.body = testFieldV
                }
                issue.customFields."Test Field".value = replica.customFields."Test Field".value
            }
        }


        ie added a line to sync to the value to a custom field in Zendesk to see if both of the if statements are working (which they are since the value is synced to that custom field in zendesk. So it looks like the below line is the issue:

        commentHelper.addComment(issue.comments){comment ->
                                                        comment.internal = false
                                                        comment.body = testFieldV
                }

        And does not successfully add a comment to the ticket in Zendesk, Any ideas on how to fix that?

      2. Juan Grases

        Hi! My bad, the code should be:

        issue.comments = commentHelper.addComment(issue.comments){comment ->
                                                        comment.internal = false
                                                        comment.body = testFieldV
                }

        I am editing my initial answer

      3. Spencer Johnson

        Juan Grases  that worked!!! Thank you so much!

      CommentAdd your comment...