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

This widget could not be displayed.
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
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

197 views 1 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