Only Sync Field if Changes on Remote

Originally asked by Spencer Johnson on 23 October 2020 (original question)


I have a one directional sync from assignee in Zendesk to assignee in JIRA. However, if they change the value of assignee in JIRA, I don’t want exalate to overwrite it from the zendesk side.

But if they change assignee on the zendesk side, I do want to overwrite it on the Jira side.

This is what I have currently but I believe “previous” is checking the previous value on the JIRA side but I want it to check if it has changed on the Zendesk Side:

Zendesk outgoing:

replica.assignee       = issue.assignee 

JIRA Incoming:

if (replica.assignee != null || (!firstSync && replica.assignee != previous?.assignee)) {
    issue.assignee = userHelper.getByEmail(replica.assignee?.email) ?: defaultUser
} 

Answer by Spencer Johnson on 23 October 2020

This snippet is working:

Zendesk Outgoing:

replica.assignee       = issue.assignee 

JIRA Incoming:

if ((firstSync && replica.assignee != null) || (!firstSync && replica.assignee != previous?.assignee)) {
    issue.assignee = userHelper.getByEmail(replica.assignee?.email) ?: defaultUser
}

Answer by Francis Martens (Exalate) on 23 October 2020

Previous is the previous replica. That way you can check if a certain value has changed between two sync transactions.

The code snippet looks ok - does it behave as you expect?


Comments:

Spencer Johnson commented on 23 October 2020

Francis Martens (Exalate) no when you make the change on the JIRA side, it overrides the value on the JIRA side with the value on the zendesk side.

Spencer Johnson commented on 23 October 2020

I got it to work.

It should have been:

if ((firstSync && replica.assignee != null) || (!firstSync && replica.assignee != previous?.assignee)) {
    issue.assignee = userHelper.getByEmail(replica.assignee?.email) ?: defaultUser
}

Thanks Francis Martens (Exalate)

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