Groovy: validate correct link type

Hi,

I need to validate on create transition, that issue has a specific link (name: CR).

I have scriptrunner if it helps.

 

No expirience in groovy tho...

3 answers

Hi Jan,

There is an almost exact example (you only have to change the linkDescription) in the documentation

And this validator will be on the Create step.

Hi Thanos,

Maybe I'm not using this correctly but In my experience the example script does not work when creating an item. Because the item has not yet been created and the link has not been created the validator simply throws an exception every time I click "Create".

Placing the validator at the next transition always works however.

It's killing my CPU... this script.cpu_jira.PNG

Highly unlikely for that script to cause a CPU spike.

Try something more simple, like just throwing an exception every time

import com.atlassian.jira.issue.IssueFieldConstants
import com.opensymphony.workflow.InvalidInputException

throw new InvalidInputException("You must link a blocker issue at this transition")

How to add a condition to this code.. so it would work only for projectkey= CR ?

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Friday in Jira Service Desk

Looking for anyone who has switched from Zendesk to Jira Service Desk

Hi Community! The Jira Service Desk marketing team is looking for customers who have successfully switched from Zendesk to Jira Service Desk!   We’d love to hear your thoughts on the pros and ...

36 views 0 1
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