Does Post Function, conditional execution, support groovy script?

I have created a parent transition post function, and then selected "Only if condition is true".

Initially, I wrote the code:

if ("a" == "a") {

return true;

}

Thus, every time, I executed the transition, the post function triggered the parent transition, which shows that the if statement executed and returned true.

 

However, the moment I try to put in some logic, rather even a single statement, the parent transition doesnot get triggered, which I believe is because the code is either not getting executed or has an error. The code which is not working is given below:

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.issue.Issue

import com.atlassian.jira.issue.MutableIssue

import com.atlassian.jira.web.action.issue.CreateSubTaskIssue

import com.atlassian.jira.web.action.issue.CreateSubTaskIssueDetails

import com.atlassian.jira.user.util.UserManager

import com.atlassian.jira.config.SubTaskManager

import com.atlassian.jira.issue.CustomFieldManager

import com.atlassian.jira.issue.watchers.WatcherManager

 

def MutableIssue currentIssue = issue

 

if ("a" == "a") {

return true;

}

 

Want to know, can we write a script in the condition of the post function. If yes, whats the issue with the above script?

 

Regards,

Manajit.

1 answer

Hi Manajit,

Yes, you can write script in the Workflow condition, post function and Validator.

What you are trying to do here def MutableIssue currentIssue = issue ?

Taha

 

 

I am extremely sorry for the delay in the reply. Just to give you a background, what I essentially want to do is, on the transition of a subtask type "Development Subtask" to done state, check for the status of all the "Development Subtask"s of the parent story. Only if all the "Development Subtasks" are in Done state, then I want to execute a particular transition on the parent story. The pseudocode is: 1. Get the parent story of current issue 2. Get all development type subtasks of the parent issue 3. Loop through all the development subtasks. 4. Check the status of the development subtask, if it is not done then return false 5. After the completion of the loop. Return true. However, as I am new to jira groovy and am not sure of how to debug, I started writing one statement at a time and testing it with every change. The below code without "def MutableIssue currentIssue = issue" worked fine for me and the transition on the parent story was executed as I am returning a true always. import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.web.action.issue.CreateSubTaskIssue import com.atlassian.jira.web.action.issue.CreateSubTaskIssueDetails import com.atlassian.jira.user.util.UserManager import com.atlassian.jira.config.SubTaskManager import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.watchers.WatcherManager if ("a" == "a") { return true; } However, the moment I introduced the statement "def MutableIssue currentIssue = issue" in the code as is given in my original question, it stopped working. I don't know what is going wrong and also don't have a clue as to how to debug. Do let me know, if you can help me understand how to debug or give me a snippet which I can then take ahead. Manajit.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,296 views 14 20
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot