Forums

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

How to create a subtask when in a task it add a flag?

Jose Luna López April 24, 2019

I would like to add a subtask automatically when I add a flag on a issue. 

 

 

We had the plugin ScriptRunner.

3 answers

0 votes
larry.lowe
Contributor
May 19, 2020

@Jose_Luna_López

  1. I used scriptrunner to create a new listener
  2. Choose the option to create a sub-task from the listener templates
  3. Select "Issue Updated" as the event
  4. Enter the below code for the "Condition":
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder

def change = event?.getChangeLog()?.getRelated("ChildChangeItem").find {it.field == "Flagged"}
if (change && ('Impediment' in cfValues['Flagged']*.value)){
return true;
}

 I was able to get this working in Jira Data Center 7.13

0 votes
Larry Lowe May 19, 2020

 

 

0 votes
Nic Brough -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 Leaders.
April 26, 2019

I am not sure this is possible - if adding a flag fires an event, then you can write a listener to catch the event and create a subtask, but I have a feeling no event is fired by flagging or un-flagging.

Suggest an answer

Log in or Sign up to answer