How to check if project already has an Issue?

Originally asked by Sai Thakur on 27 August 2021 (original question)


It is possible to determine if an issue of a particular issuetype already exists in a remote project before exalating? if so then connect the current ticket with it instead of exalate process creating a new one. The project key is passed via a field on the issue type.Thank you.


Comments:

Daniel Carvajal commented on 27 August 2021

Hi Sai

This is possible however, can you elaborate on the use case? as with issuetypes you will be restricted to 5 or so issuetypes (Bug, Task, Sub-task, Epic, Story), did you mean Issue Ids?

Cheers,

Daniel

Sai Thakur commented on 27 August 2021

We have custom issuetype that defines attributes of each project. Since this issue defines project properties, only one issue of this type is created for each project.

Generally a project is coroboration of different parts of the organization who have JIRA instances of their own because of disjoint set of users.

Project now needs exits on multiple Jira instances with projects properties that need to be in-sync across different Jira instances.

Project is generally lead by one of the parities involved hence project properties is created in one of Jira instance and then needs to be created in it counterpart projects in other Jira instances.

Let me know if more clarification is needed.

Daniel Carvajal commented on 27 August 2021

Hi Sai

Ok, I believe an adaptation of the syncHelper methods described here: https://docs.idalko.com/exalate/x/cwt1Aw might be the way to go.

The following script stops sync if an issue with an entity id and entity type is synced through a different connection.

if (syncHelper.isUnderSync(issue.id, entityType, “B_to_A”)){return;}

So departing from this you could try:

if (syncHelper.isUnderSync(entityType, “B_to_A”)){return;}

Hope this is helpful.

Cheers,

Daniel

Sai Thakur commented on 28 August 2021

Thank you. That should help with syncing with multiple connections at once but see it possible to check if an issue exists in a project before the sync process starts. If issue already exists, it would be prefereable to connect the existing issues instead of exalating a new one.

Thank you,

Sai Thakur

Daniel Carvajal commented on 30 August 2021

Hi Sai

If I understand the problem correctly, we believe that the problem can be solved by adding a tag/label or reference once the first ticket is created.

In other words you can configure a field to get the issue URL added when the ticket is created using a sync back after processing:

On the destination side (external) in the incoming sync processor

1234 // trigger a sync back to the internal instance``if``(firstSync){``syncHelper.syncBackAfterProcessing()``}

On the source side (internal) in the incoming sync processor

(You can also replace “remoteIssueUrl” for “replica.key” or even “replica.type?.name”)

12 // update the custom field 'remote issue key' with the key of the newly created issue``issue.customFields.``"remote issue key"``.value = remoteIssueUrl

This way you will know before exalating an issue you will have a reference to know if it has already been exalated already.

Let me know if this is helpful,

Daniel

Sai Thakur commented on 30 August 2021

Thank you for your reply. Apologies if I was not clear. Below is the flowchart to explaining the process. Hope this would understand the problem statement.