1
0
-1

Hi,


whats the easist way to add an internal comment on outgoing sync with date and time ?

    CommentAdd your comment...

    2 answers

    1.  
      1
      0
      -1

      Hi,


      so the steps to set it up is:


      1. Add this to the incomming sync on JIRA side: 
        if (firstSync) {
           syncHelper.syncBackAfterProcessing()
        }


        2. Add the custom field Sync Date of type Date
        3. Add the follwoing to our incomming sync ?
        if (issue.customFields."Sync Date" == null) {
           issue.customFields."Sync Date".value = new Date()
        }

        Step 3, would that not just update first sync date ?
        Regards
        Mikael B


      1. Francis Martens (Exalate)

        How do you mean
        >  Step 3, would that not just update first sync date ?



        What will happen.


        • A ticket gets exalated towards Jira.
        • Jira returns the confirmation with the syncBack
        • The zendesk updates the local custom field with the current date



        The custom field will contain the date that the sync has been confirmed



      CommentAdd your comment...
    2.  
      1
      0
      -1

      Hi Mikael Bohlin


      • Is this a sync zendesk to jira, and in what direction does the comment needs to flow
      • Does the comment body needs to be annotated on the outgoing side or the incoming side
      • What date/time are you alluding to



      Francis

      1. Mikael Bohlin

        Hi,


        outgoing sync from Zendesk to JIRA. We would like it to be added as an internal comment in Zendesk only.

      2. Mikael Bohlin

        Hi,


        date and time should be the date and time when the outgoing sync is started.


        Regards


        Mikael B

      3. Francis Martens (Exalate)

        outgoing sync from Zendesk to JIRA. We would like it to be added as an internal comment in Zendesk only.

        So - JIra comments need to be added as internal comment to zendesk


        date and time should be the date and time when the outgoing sync is started.
        Would the date and time of when the comment was added to the Jira be ok?

      4. Mikael Bohlin

        Hi,


        if the comment and date is the date when it was synced with JIRA. This is for getting a timestamp in Zendesk to be able to track when the sync is initiated.



      5. Francis Martens (Exalate)

        Regarding the time when the sync is initiated ...

        Add following to the replica

        Outgoing
        replica.customKeys."Sync date" = new Date()



        This then can be used in the incoming to update a date (or add to the comment)

        Incoming
        // add a custom field of type date
        issue.customFields."Sync Date".value = replica.customKeys."Sync date"
      6. Mikael Bohlin

        Hi,


        i just want to add an internal comment in (In Zendesk) to the ticket that is synced . The comment should contain:


        Ticket sync initiatet: "Date and Time"


        OK?


        Regards

        Mikael

      7. Mikael Bohlin

        Hi,


        can i write something like this in the outgoing syncrule:


        issue.addedComments = replica.addedComments.collect{ c →

        def Syncdate = newDate()
        c.body = "Synk started:"+Syncdate
        c
        }
        issue.comments = commentHelper.mergeComments(issue, replica, {it.internal = true})

      8. Mikael Bohlin

        Hi,


        can i do like this ?: Will this work ?


        1) Create a custom field in Zendesk "Sync Date"

        2) Add the following to the outgoing sync script: 

        issue.customFields."Sync Date".value= newDate()
      9. Francis Martens (Exalate)

        Hi Mikael Bohlin

        You can't set the issue/ticket on the outgoing sync because this could create loops.
        What you can do is to add a syncBackAfterprocessing in the incoming sync on Jira.

        So

        Incoming Sync - Jira
        if (firstSync) {
           syncHelper.syncBackAfterProcessing()
        }



        on Zendesk, incoming sync, assume there is a custom field - Sync Date

        Incoming Sync - Zendesk - Untested
        if (issue.customFields."Sync Date" == null) {
           issue.customFields."Sync Date".value = new Date()
        }



        Hope this helps

      10. Mikael Bohlin

        Will this work for multiple updates ? That is if a ticket is synced serveral times ?

      11. Francis Martens (Exalate)

        Yes, that is why there is the if statement.
        Once that it has been updated, it will remain.

        If you would like to have the sync date updated each time that the sync happened, just remove the if statement

      12. Mikael Bohlin

        Ok,


        but we want to use this for monitoring the last sync date. I guess we can remove the "first sync condition ?

      13. Francis Martens (Exalate)

        Yes - I assumed the requirement was 'first sync'

      CommentAdd your comment...