scriptrunner post function : how to block transition

How can I block/cancel transition if some customfield values are not correct like a startdate >= enddate ?

And of course, showing a message to the user.

Here is my script on the create event:

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()

def dateDebRsv = customFieldManager.getCustomFieldObject("customfield_12100")
def dateFinRsv = customFieldManager.getCustomFieldObject("customfield_12101")
def dateMEP = customFieldManager.getCustomFieldObject("customfield_12102")
def dateDebGar = customFieldManager.getCustomFieldObject("customfield_12103")
def dateFinGar = customFieldManager.getCustomFieldObject("customfield_12104")

def dateDebRsvValue = issue.getCustomFieldValue(dateDebRsv)
def dateFinRsvValue = issue.getCustomFieldValue(dateFinRsv)
def dateMEPValue = issue.getCustomFieldValue(dateMEP)

if (dateDebRsv >= dateFinRsv)
	// Show error message
	// Block transition

if (dateMEPValue != null)
	issue.setCustomFieldValue(dateDebGar, dateMEPValue + 1)
	issue.setCustomFieldValue(dateFinGar, dateMEPValue + 15)

1 answer

1 accepted

0 vote
Tarun Sapra Community Champion Jun 29, 2017

Hello Fabrice,

If you want to block/cancel a transition then you should use the "Validation" phase of the transition. As post-function phase means transition has already happened thus you should use the validation phase instead of post-function phase.


yes, I did that... and throw a new InvalidInputException to show error message.

thanks for your help.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Wednesday in Jira

Join our webinar: How 1B+ feature flag events helped us build the new Jira

Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...

116 views 0 3
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