Inherit parent task text(under description field) of its corresponding sub-task description along with some hard coded text
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.event.type.EventDispatchOption
def issue = event.issue
if (!issue.issueType?.subTask) {
return
}
def parentIssue = issue.parentObject
if (!parentIssue) {
return
}
def parentDesc = parentIssue.description ?: "<No description available>"
def finalDescription = """\
1.Sub Task description:
2.Acceptance criteria:
3.Storage location:
4.Description of mother task:
${parentDesc}
"""
// Run asynchronously so Jira finishes its own processing
Thread.start {
sleep(4000) // wait 4 seconds for Jira's copy process
def issueService = ComponentAccessor.getIssueService()
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.setSkipScreenCheck(true)
issueInputParameters.setDescription(finalDescription)
def validationResult = issueService.validateUpdate(currentUser, issue.id, issueInputParameters)
if (validationResult.isValid()) {
issueService.update(currentUser, validationResult, EventDispatchOption.ISSUE_UPDATED, false)
} else {
log.warn("Description update failed: ${validationResult.errorCollection}")
}
}
Excepted Output:
While creation of sub-task, description field of sub-task shall contain
- Hard coded text i.e.
- Inherited text from Parent task i.e.
Actual Output:
While creation of sub-task, description field is filled with parent description and not the hard coded text