Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How can I tell a rule not to create duplicate work items?

Antonia
Contributor
July 16, 2025

I have built a rule that creates a work item when an asset is older than 3.9 years. Every time the asset is updated, a new work item is created. And I would like to have a query that first checks if there is already a work itemwith the same name, if yes then no new work item should be created.

Screenshot 2025-07-16 090148.png

1 answer

1 accepted

1 vote
Answer accepted
Marc - Devoteam
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.
July 16, 2025

HI @Antonia 

Use a Lookup Work Item action to find an issue with the same name.

The based on IF/ELSE, if already found add for example a comment to the issue ELSE create a new issue.

See this community post for more information; Jira-Automation-Look-for-existing-issue-and-comment 

Antonia
Contributor
July 16, 2025

Hi @Marc - Devoteam

thanks for your help.

Screenshot 2025-07-16 144745.png

 

The based on IF/ELSE, if already found add for example a comment to the issue ELSE create a new issue.

What do you mean by that? Do I usually have to create a new component for this or can I enter it in the field for the JQL? I've also looked at the other post, but I don't quite understand it, I can't really get any further. I would prefer it if the action simply checked whether the summary/title already exists.

Marc - Devoteam
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.
July 16, 2025

Hi @Antonia 

You need to add a JQL in the lookup issues, the will find information based on the object updated.

So you JQL in the lookup should be something like;

type = "hardware change" and summary ~ "printer xyz"

What is set in the created issue that identifies this relates to the specfic asset object that triggered this rule.

 

Antonia
Contributor
July 16, 2025

Hi @Marc - Devoteam ,

thank you for your help!

Well, unfortunately that makes less sense, because the title always changes.

For example, when I create a ticket using the rule, it says “PC 1” (this PC1 comes from the asset name), so I would always have to filter by the asset name, but it always changes in the title, so I can't specify anything fixed in the JQL.

Example of a duplication

1. title for {{object.Hardware Device}}

2. Title for {{object.Hardware Device}}

 --> Title for PC1

--> Title for PC1

type = “Hardware Change” AND summary ~ “PC” would therefore be incorrect.

 

Do you have another idea? :)

 

 

Antonia
Contributor
July 16, 2025

Hi,

I tried:

type = "Hardware Change" AND summary ~ "{{object.Hardware Device}}"

 Screenshot 2025-07-17 082646.png

But it still created a new work item with the same name:

Screenshot 2025-07-17 082837.png

Marc - Devoteam
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.
July 17, 2025

HI @Antonia 

What does the log provide if you make a log action {{object.Hardware Device}}

Other option on creating the new issue, can you set the asset field in the issue based on the object that is changing?

Then in the lookup you could JQL on: type = "Hardware Change" and <assets-customfield> = <object-set-in the-field>

Antonia
Contributor
July 17, 2025

Hi  @Marc - Devoteam

thank you for your time!

 

Log:

Screenshot 2025-07-17 100917.png

Then in the lookup you could JQL on: type = "Hardware Change" and <assets-customfield> = <object-set-in the-field>

So, the Asset Custom field is called "Asset2" :

type = "Hardware Change" AND asset2 = "{{object.Hardware Device}}"

Do you mean like that?

Object.hardware Device is the asset label

I tried it, but it doesn't work.

 

So, here is the updated rule, maybe the order of the actions is wrong:

Screenshot 2025-07-17 101617.png

Marc - Devoteam
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.
July 17, 2025

Hi @Antonia 

What kind of information is in the newly created issue.

Is the field asset2 on the new issue, is this an asset field and if so what is the value of that field in the new issue?

The JQL we need is to find details on the new issue, so it will determine if this is already there, so no new issue will be created.

What does the log say on using "{{object.Hardware Device.label}}"

Antonia
Contributor
July 17, 2025

Screenshot 2025-07-17 104141.png

Now the rule doesn't work at all anymore, and I have no idea why. Not even when I undo the changes. There's nothing showing up in the logs either—only that I made some changes. But at least now you can see what kind of custom asset field it is. And that could also be used to identify the tickets

Antonia
Contributor
July 17, 2025

Edit: It took 5 minutes till the rules starts. But the logs says nothing special, it says just "log"

Marc - Devoteam
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.
July 17, 2025

HI @Antonia 

Then can sometime happen on rules by asset triggers, you will have to wait some time.

I think I was wrong on the smart label, I think it should be {{object.Hardware Device.Label}}

And add a Re-Fetch action after the creation of the new issue and before the lookup.

Antonia
Contributor
July 17, 2025

Screenshot 2025-07-17 115740.png

Log says:

Can't run component as it requires work item(s) in the context. More than likely you have a trigger that doesn't insert work items into the rule chain. e.g. Scheduled rule not running a JQL query. Creating a work item does not put a work item into the context, you have to branch on it to update it.

Marc - Devoteam
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.
July 17, 2025

Hi @Antonia 

Then use a branch, based on most recent created issue and do the lookup in the branch, also the log action for the time being

Antonia
Contributor
July 17, 2025

I made it! I done it a bit different like you said, but it works:

Screenshot 2025-07-17 135934.png

I have moved the lookup function up one and then a smart value is added and only then is the ticket created.

 

Thank you @Marc - Devoteam for your help!

Like Marc - Devoteam likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events