How to do issue type validation before creating issue?

I wish to validate the issue type selected before user create issues. How to implement it in jira cloud?

1 Like

Hi @DhineshDhanapal,
I don’t know your exact use case, but it sounds like something that can be solved by using workflow validators.
Connect
Forge
Once the validator is implemented with an expression like issue.issueType.name=="Bug", you need to add it to a proper transition in a project’s workflow, and then it should be possible to create only issues with issue type “Bug”.

Let me know if it was helpful.
Regards,
Beata

2 Likes

Hi @BeataSzturemska

Thanks for your reply. My use case is, I am using openCreateIssueDialog for creating issue and prefilling issue type in that jira create issue dialog. I need to validate the issue type before creating issue or I should not allow the user to change issue type. Can you share the way how to use it?

Thanks,
Dhinesh Dhanapal

Do you need multiple issue types in that project?
If only one issue type is enough, then you can simply limit it in issue type scheme.

Otherwise, I think validators are the way to go.
Than you can build even more complicated expression like
(issue.issueType.name=="Bug" && user.groups.some(group => group=="regular users")) || (issue.issueType.name=="Story" && user.groups.some(group => group=="super users")).

Then members of regular users group can create Bugs only, and super users can create Stories.

I have 5 pages. in each page, I should create one type of issue(only able to create based on the type of the page). I am not depending on the type of users. I hope it will help you to understand the use case.

Regards,
Dhinesh Dhanapal

Now I fully understand you use-case, but I have no clue how to solve it easily.
I’m pretty sure, you can setup some initial value of the issue type, on create issue dialog, but I have no idea how to prevent changes of issue type field. From what I remember, you can’t exclude that field from create issue view.

So the only idea that I have for now is implementing your custom create issue dialog, create the issue with the expected issue type by calling POST /rest/api/3/issue, and passing values read from your custom dialog.

Another option may be creating Jira Service Management project and having multiple forms - separate for every issue type. (I’m sure it’s possible, but I haven’t configured it).

I feel you may give UI modifications a try - here is the full documentation (a guide and fields API is linked within this page): https://developer.atlassian.com/platform/forge/manifest-reference/modules/jira-ui-modifications/

You should be able to apply different modifications on the Global Issue Create form based on context (project + issue type)

Please let me know if you will have some UI modifications questions after reading those docs. Keep in mind it’s for Jira Software only.