I have a drop-down with values - Receptionist, HR, IT etc.,
If receptionist is chosen from the drop-down, few sub-tasks configured for that role should be created (not all)
If HR is chosen from the drop-down, few sub-tasks configured for that role should be created (not all)
If IT is chosen from the drop-down, few sub-tasks configured for that role should be created (not all)
May I know how to configure this in Jira?
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.MutableIssue;
import org.apache.log4j.Category;
import com.atlassian.jira.util.ImportUtils
import com.atlassian.jira.issue.fields.config.FieldConfig;
import com.opensymphony.workflow.WorkflowContext;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder;
import com.atlassian.jira.issue.ModifiedValue;
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.IssueImpl
CustomFieldManager cfm = ComponentManager.getInstance().getCustomFieldManager();
issueManager = ComponentManager.getInstance().getIssueManager()
issueFactory = ComponentManager.getInstance().getIssueFactory()
authenticationContext = ComponentManager.getInstance().getJiraAuthenticationContext()
subTaskManager = ComponentManager.getInstance().getSubTaskManager()
MutableIssue myIssue = issue
log = Category.getInstance("com.onresolve.jira.groovy.PostFunction")
CustomField cfAutoID = cfm.getCustomFieldObject("customfield_12131");
def autoID = myIssue.getCustomFieldValue(cfAutoID);
log.info("Custom field value -"+autoID);
def addSubTask(issueTypeId, subTaskName) {
log.error("Adding subTask: " + subTaskName)
def issueObject = issueFactory.getIssue()
issueObject.setProject(issue.getProject())
issueObject.setIssueTypeId(issueTypeId)
issueObject.setParentId(issue.getId())
issueObject.setSummary(subTaskName)
issueObject.setAssignee(issue.getAssignee())
issueObject.setDescription(subTaskName)
issueObject.setReporter(issue.getReporter())
subTask = issueManager.createIssue(authenticationContext.getUser(), issueObject)
log.error("issue.getGenericValue(): " + issue.getGenericValue())
subTaskManager.createSubTaskIssueLink(issue.getGenericValue(), subTask, authenticationContext.getUser())
// Once all the subtasks have been created
// Update search indexes
ImportUtils.setIndexIssues(true);
ComponentManager.getInstance().getIndexManager().reIndex(subTask)
ImportUtils.setIndexIssues(false)
}
switch(autoID) {
case "Every User / Standard Setup" :
addSubTask("5",'Please setup ABCD');
addSubTask("5",'Please setup DCBA');
addSubTask("5",'Please provide XYZ');
break;
case "HR" :
addSubTask("5",'Please start Payroll');
addSubTask("5",'Please setup account');
default:
addSubTask("5",'Please setup ABCD');
}
However, each of the sub-task should be assigned to a different assignee. Also, I need certain parent fields to be copied over to sub-task. How can I achieve this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have added this
switch(subTaskName) {
case "Please setup ABCD" :
issueObject.setAssignee(username)
break;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you want to do this as part of a workflow transition, then Create on Transition Plugin for JIRA will do that.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Bob,
I am already using your plugin from long time. Very helpful plugin.
But in this case, I have around 14 custom field drop down options and 23 sub-tasks out of which only certain of them get created based on the drop down selection. As the list might get too huge with your plugin, I was looking for other options like scripting. Is there a way that I can shrink them into very less number of actions using 'Create sub-task on transition'?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sounds like a custom script is necessary if there are so many combinations.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There's no configuration of this source out of the box for JIRA.
Some alternatives include running a Jelly script to execute on a filter to create a subtask or using a remote API to create this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Based on online references, I am planning to user Scriptrunner for this. Any idea on how to do the customization based on custom field value selection?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.