Adaptavist Jira Cloud Create Sub Task Post Function Additional Code Examples

Created by Kristian Walker last modified
 * "The code examples below should be added to the 'Additional Code' box on the Create subtask postfunction in order to set the assignee on the subtask to the assignee of the parent issue 
 * All right, title and interest in this code snippet shall remain the exclusive intellectual property of Adaptavist Group Ltd and its affiliates. Customers with a valid ScriptRunner 
 * license shall be granted a  non-exclusive, non-transferable, freely revocable right to use this code snippet only within their own instance of Atlassian products. This licensing notice cannot be removed
 * or amended and must be included in any circumstances where the code snippet is shared by You or a third party." 

// -------- Set the assignee to the assignee from the parent issue --------

// Get the assignee's Account Id from the parent issue
def parentIssueAssignee = issue.fields.assignee.accountId
// Define the map required to set the assignee using their Account ID
def user = [id: parentIssueAssignee] as Map
// Set the assignee of the subtask
subtask.fields.assignee = user 

// -------- Set the subtask summary to the summary of the parent issue with some extra text appended to it --------
// Define the extra text to append to the Summary field
def stringToAppend = " My extra text to append to the summary"
// Set the Summary of the subtask to the Sumamry of the parent issue and then append the additionl text onto the end of it. 
subtask.fields.summary = issue.fields.summary + stringToAppend.toString()

Comments (0)


You can clone a snippet to your computer for local editing. Learn more.