Avoid duplicate issue creation using Jira Automation

Jamshaid
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 18, 2024

I have some tasks in Jira and one field has some values. I have to create tasks in different projects based on values in that field. I can create tasks successfully but I am having an issue. I want to make sure that an issue is not created for the second time if it was created and linked to that ticket once. I am able to create a link between the both issues using clones Link. But, it always creates duplicate issues everytime the issue is updated. I am unable to get a logic to create the issue once only.  I have tried adding the second condition that is shown in AND but it does not work

Here is my current automation rule.

 

Screenshot from 2024-10-18 16-22-26.png

 

This is the variable called relatedCT.

Screenshot from 2024-10-18 22-33-32.png

 

This is for-each

Screenshot from 2024-10-18 22-37-45.png

 

This is the create issue 

Screenshot from 2024-10-18 22-38-35.png

 

This is my logic here

de-duplicate logic: this is to ensure for each issue in CM1, only 1 issue is created in one of the slave projects. for instance, for CM1_1, in CT1, there should only be one issue created for CM1_1.

The duplicate could happen in these scenarios: 1. more than 1 question in CM triggers the creation of a new issue. There will be about 30 questions. Some questions are multiple-select. so there will be about 60 data points. it would be hard to control the questions so they do not result in duplicate issue creation. therefore we need a backend logic.

Here is the value in the custom field mentioned in my rule

CT163,CT162,CT161,CT160,CT156,CT155,CT153,CT149,CT146,CT137,CT116,CT83,CT82,CT81,CT79,CT66,CT60

I have made sure that these values are never duplicated via the scriptrunner script while setting these values here.

Now, I have a concern that if the issue is updated a second time, it should not create the tickets again and link them to the current issue.

3 answers

1 vote
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 18, 2024

Hi @Jamshaid 

How do you determine if an issue is a "duplicate"?  Is the branch variable {{customCT}} used to set a value in the new issue so it can be checked for uniqueness?

Please show an image for the Create Variable action of {{relatedCT}} to clarify the input values to the branch.

Please show how you are are selecting different projects in the Create Issue action.

Kind regards,
Bill

Jamshaid
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 18, 2024

Hi @Bill Sheboy , i have updated my question. COuld you please look into it again?

THanks 

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 18, 2024

Thank you for the additional information, @Jamshaid 

FYI - you describe the removal of duplication in the custom field using a ScriptRunner script.  That could be enforced further in the advanced branch by using distinct:

{{relatedCT.split(",").distinct}}

 

You appear to be making the new issues unique by concatenating the values of the trigger issue's key and the branch variable, {{customCT}}

However your rule does not check if any issues exist that match that pattern with the Related Issues Condition's JQL.  Perhaps add that also using the DOES NOT CONTAIN !~ JQL operator:

project = CT163 AND summary !~ "{{customCT}}"

 

Jamshaid
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 18, 2024

@Bill Sheboy thanks for further guidance. 

The JQL does not support using smart values. How do I avoid duplication of issues in this case?

 

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 19, 2024

In an automation rule, smart values can be used in JQL.  The expression I suggested is what will detect any duplicates.

0 votes
Manoj Gangwar
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 18, 2024

Hi @Jamshaid ,

You can add a condition using the Summary !~ "created issue summary" before creating the Issue.

Jamshaid
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 18, 2024

how would i do that?

Jamshaid
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 18, 2024

@Manoj Gangwar Is not there any other way? The summary might be different for the issues created.

0 votes
Dick
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 18, 2024

Hi @Jamshaid 

There seems a bit of a mismatch of variables in your automation. 

{{relatedCT}} is defined, yet {{customCT}} is used (twice). As the latter is undefined, it yields a null object that never triggers your conditionals. 

 

Hope your automation will at least run after this,

Dick

 

 

Jamshaid
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 18, 2024

Thanks @Dick for responding. I have used customCT variable in branch and have defined it in the branch as well. You can see my configurations for this variable. I believe that is not the caseScreenshot from 2024-10-18 17-10-33.png

 

Dick
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 18, 2024

Hi @Jamshaid 

I think the text under the advanced branch inlay in your picture tells you not to split the stuff as it is carried out for each value in the list.

And for clarity, can you whip up the definition of relatedCT as well ?

 

Thanks for clarifying your problem,

Dick

Jamshaid
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 18, 2024

Sorry for the confusions @Dick

I have comma separated values in the relatedCT custom field. I have to create a different task in a different project based on each value. Task creation works fine as I mentioned in my question but the issue occurs when it creates duplicates. I want only single issue created

 

Dick
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 18, 2024

To assess the duplicates: do you see a double round of statements in the automation log?

 

Jamshaid
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 18, 2024

@Dick i could not get your question. Here are my logs

Screenshot from 2024-10-18 18-46-05.png

Dick
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 18, 2024

Hi @Jamshaid 

from the log, I conclude that the foreach loop only is run for the log action. The condition check is only run once. 

Shouldn't your logs contain as much condition checks as there are entries in the relatedCT variable?

Jamshaid
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 18, 2024

@Dick I have updated my question adding more details. Could you please have a look at it.

Dick
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 21, 2024

Hi @Jamshaid , I've read your updated question three times.

I think your logic would have to address an occurring change to the original ticket in the master project. You can do so by using the change history to access the previous and current value, then determine if action (creation of a ticket in the slave project) is warranted or not. Assessment goes like this:

Old Value:  {{changelog.[fieldname].fromstring}}

New Value:  {{changelog.[fieldname].tostring}}

I think that if the old value is empty, you should create the ticket, and when it's full, this action would not be necessary (or maybe a change in the slave-ticket might be in order).

 

Curious as to whether I've interpreted your renewed query

Dick

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events