Forums

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

workflow custom script validator

Pankaj Mehta
Contributor
May 11, 2023 edited

Hi All,

 

Q.) for Task issue type while moving to close transition in workflow: 
      Error would be displayed if the task have any open subtasks. (open meaning issue not in any done status category)
      Error Message: "All open subtasks needs to be closed"
    > I have written this script , but it is not working.
       import com.opensymphony.workflow.InvalidInputException;

        if (issue.getSubTaskObjects().any { subtask -> subtask.getIssueType().getName() ==               'Task' && subtask.getStatus().getName() != 'Done' })
       {
        throw new InvalidInputException("All subtasks need to be closed");
        }
         Where we need to change?

1 answer

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.
May 15, 2023

I wouldn't bother with a script.  There's a built-in condition for "only allow transition if all sub-tasks are in one (of a list of) status"

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
atlassian, mindful member, mindful member badge, atlassian community, community kudos, community giveaway, atlassian swag, community values, empathy and kindness, badge challenge, atlassian learning, community engagement, swag giveaway

Earn a Badge, Win a Prize 🎁

Earning the Mindful Member badge proves you know how to lead with kindness, plus it enters you into a giveaway for exclusive Atlassian swag. Take the quiz, grab the badge, and comment on our announcement article to spread the good vibes!

Start here
AUG Leaders

Atlassian Community Events