How to (natively) block users from created specific issue types

Antoine _Klee Group_
Contributor
September 11, 2023

We few times got asked to block the creation of some specific issues types from users except a specific set (such as admins or app users).

As you may know, the "create issue" sadly transition does not support conditions.

Let me therefore share some rather unknown workaround solution.


As it is not possible to add conditions to the create issue transition on workflows, the only way to set up the requested behaviour is through the use of validators.

Some apps, such as JWME allow to direclty select specific users through the "User Validator" with a lot of settings such as the group or role membership.

Natively, there are two ways of doing so.

Using a permission validator

Creating an issue relies by default on the "create issue" permission. It is possible to add another Permission Validator  to the transition and select the required one so that all users do not have it except targeted ones.

For example, if all the users but admins can create the task issues, we simply need to add the "Only users with administer projects permission can execute this transition." validator.

In case we want to give this permission to more users, we could as well use another permission which is not often used, for instance, the View aggregated data permission.

We can then edit the permissions scheme of the project so that a specific role or groups gets this permission.

Cons:

  • this method plays with permissions and permissions give, well, permissions so those need to be used wisely.
  • The error message is not customisable and therefore not very explicit for our use case.
    Capture d’écran 2023-09-11 172734.png

Using the not so famous Field has been modified Validator

Another way of doing it is by making use of the Field has been modified validator, tunning the Groups exempt from the validator to set up an allowlist. The following parameters need to be used:

  • Field: Creator
  • Groups exempt from the validator: the group(s) that we wish being allowed to create the issues.
  • Error message: an explicit error message

Now, all the users part of the designated group will be allowed to create issues of this type. Others will see a nice custom message:

Capture d’écran 2023-09-11 173710.png
Capture d’écran 2023-09-11 173428.png

Pros:

  • This technique does not rely on a permission.
  • The error message is customisable to make it look seamless.

Con: It is not possible to use roles or single users, but hey that's a workaround right?

 

Why the "creator" field you might ask? Well because this field is automatically populated with the reporter's value when clicking the create button. Plus it cannot be changed in the create screen.


Hope you will like this little hack 🐱‍🏍

0 comments

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events