Restrict sub-tasks by issue type
I am trying to restrict sub-task creations based on issue types. I have three custom subtasks and four custom issue types. For each of the four issue types, I want the ability to only create the associated sub-task.
The associations are: IssueType_1 -> Subtask_1 IssueType_2 -> Substask_1
IssueType_3 -> Subtask_2
IssueType_4 -> Subtask_3
I have been successful locking these three custom sub-tasks to their associated issue type, but I cannot seem to prevent the default sub-tasks, Sub-task and Technical Task from being created under these 4 issue types.
I have created a workflow for these issue types, and added the following validator on the create transition: Boolean validator with math, date-time or text-string terms
((%{00040} = "IssueType_1" OR %{00040} = "IssueType_2")AND %{00014} = "Subtask_1") OR (%{00040} = "IssueType_3" AND %{00014} = "Subtask_2") OR (%{00040} = "IssueType_4" AND %{00014} = "Subtask_3") OR ((%{00040} != "IssueType_1" OR %{00040} != "IssueType_2" OR %{00040} != "IssueType_3" OR %{00040} != "IssueType_4") AND (%{00014} = "Sub-task" OR %{00014} = "Technical task"))
I am using JIRA 7.4.1
Comments (11)
-
repo owner -
reporter I wish that worked, but it is preventing me from creating any subtask, now.
I worked around with my earlier one, and found this to work (it's not as clean as your above script, but it seems to work):
((%{00040} = "IssueType_1" OR %{00040} = "IssueType_2") AND %{00014} = "Subtask_1") OR (%{00040} = "IssueType_3" AND %{00014} = "Subtask_2") OR (%{00040} = "IssueType_4" AND %{00014} = "Subtask_3") OR ((%{00040} != "IssueType_1" AND %{00040} != "IssueType_2" AND %{00040} != "IssueType_3" AND %{00040} != "IssueType_4") AND (%{00014} = "Sub-task" OR %{00014} = "Technical task"))
-
repo owner If you can't create any sub-task, then the problem is that "Subtask_1", "Subtask_2" and "Subtask_3" are not correctly written. You should write the issue type names respecting the case.
In case you have translations for your issue types, you should as issue type names the translation in the default language in your JIRA instance.
Can you, please, attach the expression you are actually using, i.e., with the real issue type names?
-
reporter Correction. I had a typo. Your script works to a point. However, when I create a subtask from a default issue type (i.e., Story), I am able to create ANY subtask (even my custom ones). The custom subtasks should be restricted to their associated custom issue types ONLY.
-
repo owner Then use:
(%{00040} in ["IssueType_1", "IssueType_2"] AND %{00014} = "Subtask_1") OR (%{00040} = "IssueType_3" AND %{00014} = "Subtask_2") OR (%{00040} = "IssueType_4" AND %{00014} = "Subtask_3")
-
reporter That's better, but now, I can't create the standard Sub-task and Technical task under standard issue types.
I don't think I made that part clear before (my bad). All of the default issue types should be able to use the default Sub-tasks, but not the custom ones. The custom subtasks should be created only by their associated custom issue type. The custom issue types should only be able to use their associated custom subtask.
-
repo owner Ok, then use:
%{00014} not in ["Subtask_1", "Subtask_2", "Subtask_3"] OR (%{00040} in ["IssueType_1", "IssueType_2"] IMPLIES %{00014} = "Subtask_1") AND (%{00040} = "IssueType_3" IMPLIES %{00014} = "Subtask_2") AND (%{00040} = "IssueType_4" IMPLIES %{00014} = "Subtask_3")
-
reporter Now everything is permissable
-
repo owner Sorry, I didn't read carefully your previous post. Use the following expression:
(%{00040} not in ["IssueType_1", "IssueType_2", "IssueType_3", "IssueType_4"] IMPLIES %{00014} not in ["Subtask_1", "Subtask_2", "Subtask_3"]) AND (%{00040} in ["IssueType_1", "IssueType_2"] IMPLIES %{00014} = "Subtask_1") AND (%{00040} = "IssueType_3" IMPLIES %{00014} = "Subtask_2") AND (%{00040} = "IssueType_4" IMPLIES %{00014} = "Subtask_3")
-
reporter That works! Thank you!!
This will be much easier to update as we create more custom filters.
-
reporter - changed status to resolved
- Log in to comment
Hi @NCATS_Lab,
Try boolean validator with the following expression: