# How to synchronize "non-bijective" statuses

**URL:** <https://community.exalate.com/t/how-to-synchronize-non-bijective-statuses/4750>\
**Category:** General Questions\
**Tags:** onpremise-jira, exalate, sync, script, migrated\_question\
**Created:** [November 4, 2024, 7:21am UTC](https://community.exalate.com/t/how-to-synchronize-non-bijective-statuses/4750 "2024-11-04T07:21:13Z")\
**Posts on this page:** 4\
**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:21am UTC](https://community.exalate.com/t/how-to-synchronize-non-bijective-statuses/4750/1 "2024-11-04T07:21:13Z")

</div>

_Originally asked by tournier on 24 June 2021 [(original question)](https://oldcommunity.exalate.com/questions/30048759)_

* * *

Hi, we try to sync issues from a public JIRA instance (we’ll call it A) with a private JIRA datacenter instance (we’ll call it B).  
It basically works  
We face an issue when we try to add “non bijective” statuses:  
An issue is always opened on B. Status is “open” on both A and B.  
status can change on A side while it does not have to change on B side. Basically 6 statuses on A side correspond to “Open” on B side  
see attched screenshot of those 6 statuses.  
To do so we used what we saw here:  
[https://docs.idalko.com/exalate/plugins/servlet/remotepageview?pageId=19629783#StatussynchronizationonJiraServer-statusSyncExternal](https://docs.idalko.com/exalate/plugins/servlet/remotepageview?pageId=19629783#StatussynchronizationonJiraServer-statusSyncExternal)

so on B side we set:  
def statusMap = [

// “remote status name”: “local status name”  
“Open” : “Open”,  
“Selected For Development” : “Open”,  
“In Progress” : “Open”,  
“In Review” : “Open”,  
“In Testing” : “Open”  
]  
def remoteStatusName = [replica.status.name](http://replica.status.name)  
issue.setStatus(statusMap[remoteStatusName] ?: remoteStatusName)

Maybe we misunderstood something. because we get the attached error:

### Support type

troubleshooting

 ![](https://europe1.discourse-cdn.com/flex018/uploads/exalate1/original/1X/88723b9da558211a5259433dba4905b2b73837c3.png)

 ![](https://europe1.discourse-cdn.com/flex018/uploads/exalate1/original/1X/d902a5ea47ebcd924b29ea5c7d7d125e1b6eb01c.png)

* * *

---

<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:21am UTC](https://community.exalate.com/t/how-to-synchronize-non-bijective-statuses/4750/2 "2024-11-04T07:21:14Z")

</div>

_Answer by tournier on 30 June 2021_

Sorry to bother, but I still have no solution on this subject, can somebody please help?

* * *

---

<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:21am UTC](https://community.exalate.com/t/how-to-synchronize-non-bijective-statuses/4750/3 "2024-11-04T07:21:15Z")

</div>

_Answer by Francis Martens (Exalate) on 26 June 2021_

tournier

Check the code fragment

```auto
def statusMap = [

// "remote status name": "local status name"
"Open" : "Open",
"Selected For Development" : "Open",
"In Progress" : "Open",
"In Review" : "Open",
"In Testing" : "Open"
]
def remoteStatusName = replica.status.name
issue.setStatus(statusMap[remoteStatusName] ?: remoteStatusName)

```

The remote status ‘IN TESTING’ is not in the statusMap, so the statement ‘statusMap[remoteStatusName] ?: remoteStatusName’ will resolve to ‘IN TESTING’.

Probably that status is not available in the workflow.  
Either add the status, or adapt the statusmap

* * *

#### Comments:

> **tournier commented on 28 June 2021**
>
> > Hi, thx for the answer.
> 
> This is precisely the case, “IN TESTING” is not in the workflow of project B. This is why I called it “non-bijective”, B does not want to know about statuses of tickets inside A workflow until it reaches a common status of both A and B projects, which is “resolved”. Before being resolved, it is only seen as “OPEN” in B’s workflow, while it goes from “Selected For Development”,“In Progress”,“In Review” to “In Testing” in A’s workflow.
> 
> We can not change B’s workflow as it is shared between several projects oj JIRA server.
> 
> When you say “adapt status map” what do you mean?
> 
> best regards

> **tournier commented on 28 June 2021**
>
> > We tried another thing and there is no error anymore, but sync only works from B to A and not from A to B (any modification from B to A is taken into account, but status modification in A project is not seen in B project)
> 
> Here is the script in A’s exalate:
> 
> OUTGOING
> 
> replica.key = issue.key  
> replica.type = issue.type  
> replica.assignee = issue.assignee  
> replica.reporter = issue.reporter  
> replica.summary = issue.summary  
> replica.description = issue.description  
> replica.labels = issue.labels  
> replica.comments = issue.comments  
> replica.resolution = issue.resolution
> 
> **if ((issue.status == “RESOLVED” )||( issue.status == ”DELIVERED”) || (issue.status ==”VALIDATED”)||( issue.status ==”CLOSED”) || (issue.status ==”REJECTED”)|| (issue.status ==”DEFERRED”))**
> 
> **{**
> 
> **replica.status = issue.status**
> 
> **}**
> 
> replica.parentId = issue.parentId  
> replica.priority = issue.priority  
> replica.attachments = issue.attachments  
> replica.project = issue.project  
> replica.fixVersions = issue.fixVersions  
> replica.affectedVersions = issue.affectedVersions// add by William  
> replica.customFields.Severity = issue.customFields.Severity //Comment these lines out if you are interested in sending the full list of versions and components of the source project.  
> replica.project.versions =   
> replica.project.components = /\*  
> Custom Fieldsreplica.customFields.“CF Name” = issue.customFields.“CF Name”  
> \*/
> 
> INCOMING
> 
> if(firstSync){ issue.projectKey = “BSFM2”  
> // Set type name from source issue, if not found set a default  
> issue.typeName = nodeHelper.getIssueType(replica.typeName)?.name ?: “Task”  
> }  
> issue.summary = replica.summary  
> issue.description = replica.description  
> issue.labels = replica.labels  
> issue.comments = commentHelper.mergeComments(issue, replica)  
> issue.attachments = attachmentHelper.mergeAttachments(issue, replica)
> 
> **if ((issue.status != “Selected for development” )&&( issue.status != ”In Progress”) && (issue.status !=”In Stand By”)&&( issue.status !=”In Review”) && (issue.status !=”In testing”)**
> 
> **{**
> 
> **issue.status = replica.status**  
> **}**
> 
> issue.customFields.“Severity”.value = replica.customFields.“Severity”?.value  
> issue.customFields.“Occurrence”.value = replica.customFields.“Occurrence”?.valueissue.fixVersions = replica  
> .fixVersions  
> // ensure that all the fixVersions are available on B  
> .collect { v -\> nodeHelper.createVersion(issue, [v.name](http://v.name), v.description) }  
> // assign affected versions from JIRA A to JIRA B  
> issue.affectedVersions = replica  
> .affectedVersions  
> .collect { v -\> nodeHelper.createVersion(issue, [v.name](http://v.name), v.description) }
> 
> In B exalate script is basically (regarding status only, I strip off all the rest of the script):
> 
> OUTGOING
> 
> replica.status = issue.status
> 
> INCOMING
> 
> issue.status = replica.status
> 
> trig is on both sides defined for creation+update
> 
> I really don’t get why statuses are not synced from A to B and only work from B to A

> **tournier commented on 28 June 2021**
>
> > For instance, comments are well synced in both ways, so issue is really only for statuses

> **Francis Martens (Exalate) commented on 04 July 2021**
>
> > You have to come up with the logic to implement the bidirectional mapping.  
> > For instance if the status on B goes to ‘In testing’, then ignore the status sync on both ends …

---

<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:21am UTC](https://community.exalate.com/t/how-to-synchronize-non-bijective-statuses/4750/4 "2024-11-04T07:21:16Z")

</div>

_Answer by Salma Nairi on 24 June 2021_

Hi

your status name are in **Uppercase** so you should modified their name in rule like that

“OPEN” : “OPEN”,

“SELECTED FOR DEVELOPMENT” : “OPEN”,

“IN PROGRESS” : “OPEN”,

“IN REVIEW” : “OPEN”,

“IN TESTING” : “OPEN”

hope to be helpful

* * *

#### Comments:

> **tournier commented on 28 June 2021**
>
> > it does not seam to be the issue here, Statuses don’t seem to be case sensitive
