Hi ,
I just added a post-function to create sub-task on the create issue --> open transition.
But it not working, mean the sub task wont created.
Could you suggest on this?
Regards,
Rajesh
I got the solution. add the postfuction to create sub-task on create issue--> open transition and
Put down the postfuction on last
In a lot of cases, this won't work. The issue isn't physically created until the end of the create process, and sub-tasks can only be created on issues that exisit. A lot of create-subtask post-functions will fail because of this.
Which post-function are you using? (I.e. which plugin?) And where exactly have you used the post-fcuntion on the list of post-functions on the transition?
package com.onresolve.jira.groovy.canned.workflow.postfunctionsimport com.atlassian.jira.config.ConstantsManagerimport com.atlassian.jira.config.SubTaskManagerimport com.atlassian.jira.event.issue.IssueEventimport com.atlassian.jira.issue.Issueimport com.atlassian.jira.issue.MutableIssueimport com.atlassian.jira.util.ErrorCollectionimport com.atlassian.jira.util.SimpleErrorCollectionimport com.atlassian.jira.workflow.JiraWorkflowimport com.onresolve.jira.groovy.canned.CannedScriptimport com.onresolve.jira.groovy.canned.utils.CannedScriptUtilsimport com.onresolve.jira.groovy.canned.utils.ConditionUtilsimport com.onresolve.jira.groovy.canned.utils.WorkflowUtilsimport com.opensymphony.workflow.loader.ActionDescriptorimport com.opensymphony.workflow.loader.StepDescriptorclass CreateSubTask extends AbstractCloneIssue implements CannedScript{ public static final String FIELD_SUBTASK_SUMMARY = 'FIELD_SUBTASK_SUMMARY' public static final String FIELD_SUBTASK_ACTION = 'FIELD_SUBTASK_ACTION' String getName() { return "Create a sub-task." } public String getHelpUrl() { "https://studio.plugins.atlassian.com/wiki/display/GRV/Built-In+Scripts#Built-InScripts-Createasubtask" } String getDescription() { return "Create a sub-task. Will optionally reopen a matching sub-task." } List getCategories() { ["Function", "Listener"] } List getParameters(Map params) { [ ConditionUtils.getConditionParameter(), [ Name:FIELD_TARGET_ISSUE_TYPE, Label:"Target Issue Type", Type: "list", Description:"""Target issue type. Leave blank for the same issue type as the source issue. <br>NOTE: This issue type must be valid for the target project""", Values: CannedScriptUtils.getAllSubTaskIssueTypes(true), ], [ Name:FIELD_SUBTASK_SUMMARY, Label:"Subtask Summary", Description:"""Optionally set the summary. If blank it will be inherited from the parent. <br>This is useful in conjunction with automatic reopening of subtasks""", ], getOverridesParam(), [ Name:FIELD_SUBTASK_ACTION, Label:"Subtask Action", Type: "list", Description:"""Optionally set an action that will be applied to a sub-task if a matching subtask already exists""", Values: CannedScriptUtils.getAllWorkflowActions(true), ], ] } public ErrorCollection doValidate(Map params, boolean forPreview) { SimpleErrorCollection errorCollection = new SimpleErrorCollection() if (!params[FIELD_TARGET_ISSUE_TYPE]) { errorCollection.addError(FIELD_TARGET_ISSUE_TYPE, "You must provide the target issue type.") } // todo: validation for issue type if set return errorCollection } Map doScript(Map params) { MutableIssue issue = params['issue'] as MutableIssue Boolean doIt = ConditionUtils.processCondition(params[ConditionUtils.FIELD_CONDITION] as String, issue, false, params) if (! doIt) { return [:] } def String subtaskAction = params[FIELD_SUBTASK_ACTION] subtaskAction = subtaskAction?.replaceAll(/ .*/, "") String subtaskSummary = params[FIELD_SUBTASK_SUMMARY] if (issue.getIssueTypeObject().isSubTask()) { log.warn ("This issue ($issue) is already a sub-task... doing nothing.") return [:] } // if we have a subtask action, and the subtask exists, and the action is applicable... do it Collection<MutableIssue> subTasks = issue.getSubTaskObjects() if (subtaskAction && subtaskSummary && subTasks*.summary.contains(subtaskSummary)) { subTasks.each {MutableIssue sub -> if (sub.summary == subtaskSummary) { if (WorkflowUtils.hasAction(sub, subtaskAction as Integer)) { try { // actionIssue(sub, subtaskAction as Integer, WorkflowUtils.getUser(params)) WorkflowUtils.actionIssue(null, sub, subtaskAction as Integer, WorkflowUtils.getUser(params), [:]) } catch (Exception e) { log.error(e.message, e) } } else { log.debug("Action not applicable") } } } return [:] } params = super.doScript (params) Issue newIssue = params['newIssue'] as Issue def subTaskManager = componentManager.getSubTaskManager() subTaskManager.createSubTaskIssueLink(issue, newIssue, getUser(params)) // GRV-115 - reindex again after creating subtask link reindexIssue(newIssue.genericValue) params } String getDescription(Map params, boolean forPreview) { ConstantsManager constantsManager = componentManager.getConstantsManager() StringBuffer sb = new StringBuffer() sb << getName() + "<br>Subtask will be created with issue type: <b>" + (params[FIELD_TARGET_ISSUE_TYPE] ? constantsManager.getIssueTypeObject(params[FIELD_TARGET_ISSUE_TYPE] as String)?.name : "same as parent") + "</b>" sb.toString() } public Boolean isFinalParamsPage(Map params) { true }}
Please look into it . Help me to change this according to how we can create subtask while creating task
Ok, that's probably going to give you some useful information in the log when you attempt it (something like "parent doesn't exist"). Could you have a look in the log? And tell us where exactly the post-function is used? (Also, confirm that "Testing" is definitely a sub-task type?)
Script workflow function : Create a sub-task.Subtask will be created with issue type: Testing
How to create subtasks on initial issue create has some tips even if you are not using Create on Transition Plugin for JIRA
yes testing is a aub-task type.
the postfunnction defined on create issue--> open transition
could yoy suggest how and wher i need to check the log.
i just joined as a fresher. so i m looking this foruim to classroom
It looks like you're new here. Sign in or register to get started.