Sync status to custom field

Originally asked by Peter Pesta on 20 April 2020 (original question)


Dear exalate team,
I’d like to ask you regarding the synchronisation of a status from the sender, to a custom field on the recipient side. The synchronisation is bi-directional, however, Company A is sending an issue to their contractor (Company B). The company A has only one status step within their WF for requests that are sent to their vendors (e.g.: Vendor), the company B has a WF with 7 different statuses. The company A would like to know just some of the steps and since the WFs arent the same, they would like to replicate the status from Company B into a custom field within jira of the company A. So if the vendor (Company B) does a status change, the status on the Company A side doesn’t change, only the cf value will be updated. However, when the issue gets to the final step within the Company B WF, this will trigger an WF status change on the Company A side. So the Company A knows that this issue was fixed by Company B.

Thank you and best regards,
Peter


Answer by Juan Grases on 20 April 2020

Hi Peter,

The sync from status to Cf can be done like this:

Outgoing processor (On Jira B):

replica.status = issue.status

Incoming Processor (On Jira A):

issue.customFields."Remote Status".value = replica.status.name

If Jira A would like to react to a specific status on B, it can be done with:

Incoming processor (On Jira A):

if(replica.status.name == "Closed"){
  issue.setStats("Closed")
}

Of course you might replace the status name and the custom field name with the real ones in your environment.

Best regards,

Juan