JQL to search for characters in summary
Asked by Pauline Hild:

Hi everyone,

I want to create an automation that prevents a task from being created twice by mistake. For this I need a JQL that searches for 4 characters (numbers or letters) between two underscores in the summary (e.g. _0110_), since these are contained in the summary of each project. If there is already a project that contains exactly these four characters in its summary, the creation of the task should be prevented.  
How must the JQL look like for this?

Best regards,

Pauline.


Answers:
author: Alex Koxaras _Relational_
body: Hi [@Pauline Hild](/t5/user/viewprofilepage/user-id/4773022)

Jira automation, if you are thinking of implementing your thought with that, it will not be of any use. Jira automation is executed as a post function and not as a validator.

Out of the box you can't search for this, meaning a set of substring located between two other characters (you could use smart values on Jira automation, but again this would not prevent your users for creating a subtask). You will need an app like JMWE, JSU, JWT. Do you have any of that?

comments: author: Pauline Hild
body: Thank you very much for your answer.

Unfortunately I don't have any of the apps you mentioned. How could I make this work with one of the apps? And is there any other way to get at least a hint when creating already existing task?


author: Vicente Dom?nguez _Decadis AG_
body: Hello [@Pauline Hild](/t5/user/viewprofilepage/user-id/4773022) and thank you [@Alex Koxaras _Relational_](/t5/user/viewprofilepage/user-id/4150197)for mentioning us!

You could use a [Jira expression validator](https://apps.decadis.net/display/JWTCLOUD/Jira+expression+validator) to validate the summary of the newly created issues with an expression similar to the following one:

```
!issue?.summary.includes("_10011_" || "_10012_")
```

In this case, the validator will allow the transition ++only if any of the texts between brackets is not included in the summary of the current issue++.

Unfortunately, we are still unable to retrieve the summaries of the projects, so the texts between brackets will need to be hard coded into the expression.

I am part of the Support Team for JWT. Please, do not hesitate to contact us if you have any question regarding JWT Cloud via our [Support Service Desk](https://support.decadis.net/).

Best regards,

Vicente


author: Pauline Hild
body: Hello [@Alex Koxaras _Relational_](/t5/user/viewprofilepage/user-id/4150197) ,

Thank you so much for responding to my question. If I understood it correctly, I would need to add the letters/numbers from all existing projects into the Jira expression validator to exclude that a project with the same characters is created twice, since matching is not possible automatically?

Beste regards,

Pauline


author: Alex Koxaras _Relational_
body: [@Pauline Hild](/t5/user/viewprofilepage/user-id/4773022) on your question you spoke about issues. Which one is it now? Issues or projects?


author: Pauline Hild
body: Sorry for the terminology confusion, it's about Issues- Tasks, to be precise (each Issue is a separate project, hence the confusion).


author: Alex Koxaras _Relational_
body: [@Pauline Hild](/t5/user/viewprofilepage/user-id/4773022)

For all future created issues you have to add a validator on the create transition of all the issue types to which you want to include this restriction. E.g. If you want not to allow users to create Tasks and Bugs if their summary contains a certain "string", then you have to apply this validator to all separate workflows. If Task and Bug are using the same workflow, then you have to apply to it once.


author: Pauline Hild
body: All right. But again, I need to specify which characters should not be in the summary, since there is no way to automatically match if the same characters are already in a summary?


author: Alex Koxaras _Relational_
body: [@Pauline Hild](/t5/user/viewprofilepage/user-id/4773022) sorry but I dont fully understand your requirement. You want to search for issue that contains any number between two underscores (_) and if you find such issue, then don't allow the creation of this issue?

E.g.

* I try to create a summary which contains " blah blah _1234_ blah blah"
* The validator searches for any summary that contains "_1234_"
* If a result is return, then the issue can't be created
* Now your user try to create another issue with summary " _2222_ blah blah blah"
* The validator runs and can't find any issue with summary that contains "_2222_"
* The issue is allowed

Is the above correct?


author: Pauline Hild
body: Yes, exactly.


author: Alex Koxaras _Relational_
body: [@Pauline Hild](/t5/user/viewprofilepage/user-id/4773022)

From further search I did unfortunately I have bad news for you concerning at least my proposed solution: It seems that it's not possible to validate an issue against others, due to restrictions from Jira (to get a bit more technical you have to use only jira expressions and you can't use REST API to retrieve a collection of issues, against which you will run your jira expression).

So to get back to your initial query:

Unfortunately you can't prevent an issue of being created via the automation. As I said, the automation runs after the issue being created. So that's the time when the automation will run. Perhaps the only thing you could consider is if you want the user to create the issue, and have an automation deleting it afterwards.. If yes, let me know and I'll try to create this rule for you.


author: Pauline Hild
body: [@Alex Koxaras _Relational_](/t5/user/viewprofilepage/user-id/4150197)

Thanks for your efforts up to here to help me out! I am interested in such an automation and would be very happy about help with the creation of the rule.


Tags: cloud

jira-work-management-cloud