Check comment with regex during transition
Asked by Alex Ziegltrum:

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


Answers:
author: Alex Ziegltrum
body: 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 :)


author: Maciej Dudziak _Forgappify_
body: Hi [@Alex Ziegltrum](/t5/user/viewprofilepage/user-id/5102308)

The described case can be addressed using any Jira expression-based validator available on the Atlassian [marketplace](https://marketplace.atlassian.com/search?query=jira%20expression%20validator).

I am from Forgappify, and we developed Jira Expression Validator, which is part of the [Workflow Building Blocks for Jira](https://marketplace.atlassian.com/apps/1233642/workflow-building-blocks-for-jira?hosting=cloud&tab=overview) 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](https://docs.forgappify.com/workflow-building-blocks-for-jira)

I hope it will help.

Cheers

comments: author: Alex Ziegltrum
body: Hey [@Maciej Dudziak _Forgappify_](/t5/user/viewprofilepage/user-id/5267224)

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


Tags: cloud

jira-service-management

jira-service-management-cloud