Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Warn that prior subtask not complete

We have a set of subtasks that need to be completed in a certain order. The subtasks are often assigned to different people. I would like to show a warning if someone starts subtask 3 before subtask 2 is completed.

We do have Scriptrunner. Is there a way to accomplish this?

1 answer

Hello Laurie,

I have an idea you may like, but I have only tested it out on Power Scripts. First I will post the equivalent script in Groovy based on this Adaptavist documentation on validators and this one on subtasks.

The idea here is to loop through all the subtasks and break the loop once the current subtask is found. If the loop completes, throw an validator error. 

def parent = issue.getParentObject().getIssueTypeObject().getName()

def subTasks = parent.getSubTaskObjects()
subTasks.each {

    if (it.getKey() == issue.getKey()) {

        break;

    }

    if (it.getStatusObject().getName() != "Done") {

        throw new InvalidInputException("subtasks","Not all previous subtasks completed")

    }

}

I did try this out on Power Scripts. Here is the script I used. Please see this documentation on subtasks routine and this one on validators.

string [] subtasks = subtasks(parent);

for (string subtask in subtasks) {

    if (subtask == key) {

        break;

    }

    if (subtask.status != "Done") {

        return false, "status", "Previous subtasks have not been completed";

    }

}

Full disclosure, I am a Product Engineer for Power Scripts and work for Anova Apps, an Appfire company.

Wow! Thanks so much for jumping in on this @Hyrum Steffensen ! Let me try it out.

Sure thing, Laurie! Please let me know how it goes!

Hyrum

Well, I'm not a developer, so I got a little stuck. I'll still digging, but would love some help if anyone can offer it.

Here's the code I'm using.

import com.opensymphony.workflow.InvalidInputException


def parent = issue.parentObject 

def subTasks = parent.getSubTaskObjects()
subTasks.each {

if (it.getKey() == issue.getKey()) {
break;
}

if (it.getStatusObject().getName() != "Testing") {
throw new InvalidInputException("subtasks","Not all previous subtasks completed")
}
}

I'm getting the following error:

The script could not be compiled:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script32.groovy: 14: the break statement is only allowed inside loops or switches @ line 14, column 9. break; ^ 1 error

.

It seems that it isn't seeing the loop. Suggestions?

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Service Management

JSM June Challenge #2: Share how your business teams became ITSM rockstars

For JSM June Challenge #2, share how your non-technical teams like HR, legal, marketing, finance, and beyond started using Jira Service Management! Tell us: Did they ask to start using it or...

171 views 6 7
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you