# Add internal comment with date on outgoing sync

**URL:** <https://community.exalate.com/t/add-internal-comment-with-date-on-outgoing-sync/4471>\
**Category:** General Questions\
**Tags:** zendesk, migrated\_question\
**Created:** [November 4, 2024, 7:00am UTC](https://community.exalate.com/t/add-internal-comment-with-date-on-outgoing-sync/4471 "2024-11-04T07:00:03Z")\
**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:00am UTC](https://community.exalate.com/t/add-internal-comment-with-date-on-outgoing-sync/4471/1 "2024-11-04T07:00:03Z")

</div>

_Originally asked by Mikael Bohlin on 24 November 2020 [(original question)](https://oldcommunity.exalate.com/questions/20122321)_

* * *

Hi,

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

* * *

---

<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:00am UTC](https://community.exalate.com/t/add-internal-comment-with-date-on-outgoing-sync/4471/2 "2024-11-04T07:00:04Z")

</div>

_Answer by Mikael Bohlin on 01 December 2020_

Hi,

so the steps to set it up is:

1. Add this to the incomming sync on JIRA side:

```auto
if (firstSync) {
   syncHelper.syncBackAfterProcessing()
}  
  
  
2. Add the custom field Sync Date of type Date  
3. Add the follwoing to our incomming sync ?

```

```auto
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

```

```auto
  
  

```

* * *

#### Comments:

> **Francis Martens (Exalate) commented on 01 December 2020**
>
> > 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

---

<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:00am UTC](https://community.exalate.com/t/add-internal-comment-with-date-on-outgoing-sync/4471/3 "2024-11-04T07:00:05Z")

</div>

_Answer by Francis Martens (Exalate) on 24 November 2020_

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

* * *

#### Comments:

> **Mikael Bohlin commented on 24 November 2020**
>
> > Hi,
> 
> outgoing sync from Zendesk to JIRA. We would like it to be added as an internal comment in Zendesk only.

> **Mikael Bohlin commented on 24 November 2020**
>
> > Hi,
> 
> date and time should be the date and time when the outgoing sync is started.
> 
> Regards
> 
> Mikael B

> **Francis Martens (Exalate) commented on 24 November 2020**
>
> > \> 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?

> **Mikael Bohlin commented on 24 November 2020**
>
> > 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.

> **Francis Martens (Exalate) commented on 24 November 2020**
>
> > Regarding the time when the sync is initiated …
> 
> Add following to the replica
> 
> **Outgoing**
> 
> ```auto
> replica.customKeys."Sync date" = new Date()
> 
> ```
> 
> This then can be used in the incoming to update a date (or add to the comment)
> 
> **Incoming**
> 
> ```auto
> // add a custom field of type date
> issue.customFields."Sync Date".value = replica.customKeys."Sync date"
> 
> ```

> **Mikael Bohlin commented on 25 November 2020**
>
> > 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

> **Mikael Bohlin commented on 25 November 2020**
>
> > 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})

> **Mikael Bohlin commented on 27 November 2020**
>
> > 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:
> 
> ```auto
> issue.customFields."Sync Date".value= newDate()
> 
> ```

> **Francis Martens (Exalate) commented on 27 November 2020**
>
> > 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](https://docs.idalko.com/exalate/x/rIKKAg) in the incoming sync on Jira.
> 
> So
> 
> **Incoming Sync - Jira**
> 
> ```auto
> if (firstSync) {
> syncHelper.syncBackAfterProcessing()
> }
> 
> ```
> 
> on Zendesk, incoming sync, assume there is a custom field - Sync Date
> 
> **Incoming Sync - Zendesk - Untested**
> 
> ```auto
> if (issue.customFields."Sync Date" == null) {
> issue.customFields."Sync Date".value = new Date()
> }
> 
> ```
> 
> Hope this helps

> **Mikael Bohlin commented on 01 December 2020**
>
> > Will this work for multiple updates ? That is if a ticket is synced serveral times ?

> **Francis Martens (Exalate) commented on 01 December 2020**
>
> > 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

> **Mikael Bohlin commented on 02 December 2020**
>
> > Ok,
> 
> but we want to use this for monitoring the last sync date. I guess we can remove the "first sync condition ?

> **Francis Martens (Exalate) commented on 04 December 2020**
>
> > Yes - I assumed the requirement was ‘first sync’
