Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

ScriptRunner Listeners - Delete subtasks based on updated custom field value

craig rayner
May 22, 2018

Hi,

 

I've created a listener to create subtasks based on a custom field radio button (Testing Required = Yes). using the built in 'create a subtask' listener. I would now like to create a listener for the opposite requirement of deleting subtasks when custom field radio button (Testing Required = No)

I'm very nooby to all of this so i've been trying to use the built in listeners as much as possible. Is this possible to do and if not is there already a solution out there?

Edit: I've found the following code, how could i edit this to do the job i want?

 

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.event.type.EventDispatchOption

// for JIRA v6.*
def user = ComponentAccessor.getJiraAuthenticationContext().user.directoryUser


// for JIRA v7.*// def user = ComponentAccessor.getJiraAuthenticationContext().userdef issueManager = ComponentAccessor.getIssueManager()

// will return a Collection<Issue> with all the subtasks of the current issue

def subTasksList = issue.getSubTaskObjects()

for (subTask in subTasksList) {    

// add a condition here if you DO NOT want to delete all the sub-tasks    

issueManager.deleteIssue(user, subTask, EventDispatchOption.ISSUE_DELETED, false)}

 

 

 

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Radek Dostál
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
March 18, 2022

How is a custom field option related to any users? What's the connection?

Asiya Shajahan
March 18, 2022

Example: If  Team/Team Assignee is the cascading field. Its options include

1. Team A

2.Team B

These A and B teams are populated with team members which are dynamically getting from another project say example :Team Manager.

I need to notify the entire Team A if a ticket is assigned with one of the A Team member. Similar as that for Team B also.

TAGS
AUG Leaders

Atlassian Community Events