Check comment with regex during transition

Alex Ziegltrum
Contributor
June 5, 2024

Hey community,

in our use-case, we need our ticket agents to enter a comment, everytime the issue gets assigned to another assignee. Therefore we have removed this particular permission in the project settings.

To assign an issue to an agent now, we need to call an action in the "actions menu". This calls a transition "Bearbeiterwechsel" (change assignee). 

In this transition, there is a validator 

The transition requires the following criteria to be valid

If a value for fields Comment, Tempo Team, Ticketbearbeiter is not provided during the transition, show the following error: Es wurden nicht alle Pflichtfelder ausgefüllt

This works well and assures, that the mentioned fields are filled.

But I am able to enter useless information in the comment field like a single dot. 

I tried to add another validator, the Regular Expression Check, but in the list of fields, the comment field is not available.

I want to add a regex check in this transition. Is that possible and do you have ideas, on how I could solve this?

Thanks, Alex

2 answers

1 accepted

0 votes
Answer accepted
Alex Ziegltrum
Contributor
September 5, 2024

For all who are interested, we solved this problem as follows:

- in the transition each field gets its own validator, so that individual error texts are possible

- the comment field is monitored with a script runner validation, checking that there are at least three words, each containing at least two digits

 

issue.comments.length > 0 && issue.comments[issue.comments.length - 1].body.plainText.split(" ").filter(word => word.length >= 2).length >= 3

 

If need be, just adapt the regex to something useful for your use case.

 

Works well for us :)

1 vote
Maciej Dudziak _Forgappify_
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.
June 5, 2024

Hi @Alex Ziegltrum 

The described case can be addressed using any Jira expression-based validator available on the Atlassian marketplace.

I am from Forgappify, and we developed Jira Expression Validator, which is part of the Workflow Building Blocks for Jira free app.

The expression you need is as follows:

issue.comments.length > originalIssue.comments.length 
&& !!issue.comments[issue.comments.length - 1].body.plainText.match('my regex')

The first part is to ensure that a new comment is added on the transition screen, and the second part is to check against the comment being added.

Here you can find the app documentation

I hope it will help.

Cheers

 

Alex Ziegltrum
Contributor
June 5, 2024

Hey @Maciej Dudziak _Forgappify_ 

thank you for your quick answer, it's very appreciated. Since it relies on an additional addon, the solution is not that easy to implement. In our organization, we need to check and verify each software for information security and data protection compliance. That being said, I am not able to use your addon as of now.

Nevertheless thanks a lot for taking the time and for looking into the problem :)

Alex

Suggest an answer

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

Atlassian Community Events