Only syncing field assignee when field assignee is being changed

Originally asked by Filip Š. on 04 May 2021 (original question)


Hello,

We have a situation where we sync field assignee, and we set assignee based on some parameters to a Project lead. After that, project lead assignee someone who will actively work on that issue.

Problem is that when anything else is changed on other side, lets say they put a comment, assignee on our side automatically switch back to Project lead. Is there possibility to sync Assignee only when Field Assignee is changed?

Kr,

Filip


Answer by Ostap Krutsko on 05 May 2021

All fields which are configured to be sync are sent from source to destination.

An assignee is an object with some properties. Each property is of type text. These properties are: key, email, displayName, username.

To sync Assignee only when it is changed you can mention it on the outgoing script on the “other side” in the next condition:

if(!firstSync){
        prevAssignee = previous?.assignee?.username
        currAssignee = issue.assignee?.username
        if (prevAssignee != currAssignee)
			replica.assignee = issue.assignee
		else
			replica.assignee = null
}			

And on the incoming script on your side (opposite to “other side”) you can mention it in such way:

if(!firstSync){
  if (replica.assignee != null)
    issue.assignee = replica.assignee
}