Scenario:
In a project management system like Jira, once a parent issue reaches the "In Development" or later status, regular users should not be allowed to create, remove, or modify any sub-tasks associated with that parent issue. This restriction is necessary to maintain the integrity of the project and prevent unauthorized changes to the task hierarchy.
Requirement:
Develop a feature or script that can enforce the following rules:
Implementation:
The solution should be implemented using a Jira add-on or a custom script that can be integrated with the project management system. The script should:
Modification and movement permission of issues (like sub-tasks) are given in the project's permission scheme listed there (click it to get the overview).
cog-wheel - system - issues - left menu: permission schemes - Your Project's Permission Scheme
There, you might want to remove some roles from:
Edit / create / delete / move issues
Thank you for your suggestion. However, I only wish to limit it to the specified status, therefore, I shouldn't be able to directly alter the permission scheme.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Utah
Is this question for Cloud or DC, or both? I see deployment Cloud, but in tags there is 'jira-server'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
JIRA: Use JIRA’s workflow conditions and validators to restrict sub-task creation based on the parent task's status. For example, you can add a condition to the "Create Sub-Task" transition that only allows it if the parent task is in a specific status.
Asana/Trello: While these tools may not have as advanced workflow automation as JIRA, you can use integrations or custom scripts with tools like Zapier to implement similar logic.
Microsoft Planner/Project: Use Microsoft Power Automate to create flows that manage task creation based on conditions like the status of a parent task.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do you have any good implementation methods? Can it be implemented using Scriptrunner scripts?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, Scriptrunner is a powerful tool that can be used to implement custom scripts and automation in Atlassian Jira. You can use it to enforce rules and conditions on issue creation, including restricting sub-task creation based on the status of the parent issue.
Implementing Restriction Using Scriptrunner in Jira
Here's a general approach using Scriptrunner to restrict sub-task creation until the parent task is in a specific status:
1. Identify the Parent Status Requirement
Determine the specific status (e.g., "In Progress," "Approved") that the parent task must have before sub-tasks can be created.
2. Create a Custom Script Validator
You can create a custom script validator in Scriptrunner that checks the status of the parent task whenever a sub-task is being created.
3. Script Example
Below is an example Groovy script for Scriptrunner that restricts sub-task creation unless the parent issue is in a specific status (e.g., "In Progress"):
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.workflow.function.issue.AbstractJiraFunctionProvider
import com.opensymphony.workflow.WorkflowException
// Get the issue manager
IssueManager issueManager = ComponentAccessor.getIssueManager()
// Get the parent issue
Issue parentIssue = issue.getParentObject()
// Check if the parent issue exists and is in the required status
if (parentIssue == null || parentIssue.getStatus().getName() != "In Progress") {
throw new WorkflowException("Sub-task creation is restricted until the parent task is in 'In Progress' status.")
}
4. Add the Script to a Workflow Validator
Go to your Jira project’s workflow and find the transition where sub-tasks can be created.
Add a "Script Validator" to this transition and paste the script.
5. Testing
Test the workflow to ensure that the validator correctly restricts sub-task creation when the parent issue is not in the required status and allows it when the condition is met.
Additional Considerations
Customization: You can customize the script based on different statuses, projects, or issue types.
User Feedback: Ensure the script provides clear feedback to users when sub-task creation is restricted.
Permissions: Make sure that only authorized users can bypass these restrictions if necessary.
This method using Scriptrunner scripts provides flexibility and control over workflows in Jira. Always test your scripts in a staging environment before deploying them to production to avoid any disruptions
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your response. Currently, the idea I can think of is to use Validators to restrict the creation of subtasks, but how can I restrict the modification and movement of subtasks?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.