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

Validate that all linked issues are DONE - ScriptRunner

Hi,

I need to add a Transition validation that checks if all the Linked Issues are in a done status category, if found this code:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
import com.opensymphony.workflow.InvalidInputException
import org.apache.log4j.Logger
import org.apache.log4j.Level



def linkMgr = ComponentAccessor.getIssueLinkManager()
for (IssueLink link in linkMgr.getInwardLinks(issue.id)) {
   		log.info(link.sourceObject.resolutionId)
        if (!link.sourceObject.resolutionId) {
            return false
            throw new InvalidInputException("Issue Links must be close before continue")
        }

}

But it only works on Condition, I need to set it on Validation  to show the error message.

Any suggestion?

I'm very basic on Groovy

2 answers

1 accepted

2 votes
Answer accepted

You can use the "simple scripted validator" for this.

I would write the condition like this:

import com.atlassian.jira.component.ComponentAccessor
def linkMgr = ComponentAccessor.issueLinkManager
linkMgr.getLinkCollection(issue, currentUser).allIssues.findAll{it != issue}.every{it.resolution}

It works perfectly. Thanks so much Peter-Dave.

Just a side note: I just noticed when you have a Condition for pending approval, the validation is skipped and don't performed.

Hi @Daniel Alonso when using it with Validators, you should throw or set InvalidInputException to invalidInputException property. But you have "return false" code on the line before throwing exception, so it will never throw an exception.

Fix for validator is:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
import com.opensymphony.workflow.InvalidInputException
import org.apache.log4j.Logger
import org.apache.log4j.Level




def linkMgr = ComponentAccessor.getIssueLinkManager()
for (IssueLink link in linkMgr.getInwardLinks(issue.id)) {
log.info(link.sourceObject.resolutionId)
if (!link.sourceObject.resolutionId) {
throw new InvalidInputException("Issue Links must be close before continue")
}

}

Thanks for the tip Martin.

Suggest an answer

Log in or Sign up to answer
TAGS

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