Forums

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

How to set Issue Picker value in Behaviours

Paul
September 11, 2019

Hi,

 

I need to set a value (another issue key, e.g. ABC-123) for an Issue Picker field in Behaviours.

How can I do it?

 

Thanks,

Paul

3 answers

1 accepted

Suggest an answer

Log in or Sign up to answer
1 vote
Answer accepted
Roland Holban (Adaptavist)
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.
May 29, 2018

The below script will delete all the subtasks associated with the issue that fired the listener event.

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

def issueManager = ComponentAccessor.issueManager
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser

// Get a list of the current issue's subtasks
def subtasks = issue.getSubTaskObjects()

// Loop through all the subtasks and delete them
subtasks.each {
issueManager.deleteIssue(currentUser, it, EventDispatchOption.ISSUE_DELETED, false)
}
craig rayner
June 5, 2018

Hi @Roland Holban (Adaptavist)

How would i change the code to only delete subtasks that begin with the word "Test" instead of deleting all subtasks?

E.g. I have subtasks such as Test Design, Test Execution, and i only want those subtasks to be deleted.

Roland Holban (Adaptavist)
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.
June 5, 2018

Inside the loop, you could add an if statement that checks whether the first 4 letters of the subtask's summary is "Test"

subtasks.each {
if (it.summary.substring(0,4) == "Test") {
issueManager.deleteIssue(currentUser, it, EventDispatchOption.ISSUE_DELETED, false)
}
}
0 votes
Roland Holban (Adaptavist)
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.
May 29, 2018

This script will delete all the subtasks associated with the issue that fired the event.

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

def issueManager = ComponentAccessor.issueManager
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser

// Get a list of the current issue's subtasks
def subtasks = issue.getSubTaskObjects()

// Loop through all the subtasks and delete them
subtasks.each {
issueManager.deleteIssue(currentUser, it, EventDispatchOption.ISSUE_DELETED, false)
}

The last portion of the code shouldn't all be commented out. The Atlassian Community code block feature is really bad. 

0 votes
Roland Holban (Adaptavist)
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.
May 29, 2018

The script below will delete all the subtasks associated with the issue that fired the listener event.

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

def issueManager = ComponentAccessor.issueManager
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser

// Get a list of the current issue's subtasks
def subtasks = issue.getSubTaskObjects()

// Loop through all the subtasks and delete them
subtasks.each {
issueManager.deleteIssue(currentUser, it, EventDispatchOption.ISSUE_DELETED, false)
}
TAGS
AUG Leaders

Atlassian Community Events