Jira version 8.20.1
Script runner version6.56.0
I want to check on a value of a customfield and throw a message if the value is not valid and not allow transition to the next state. i know I can put a validator on a transition but I do not want the user to be able to put a invalid value in that custom field in between state changes. Is there a way to validate the value when transitioning to a certain state and not allow an invalid value between state changes using script runner
Would a behaviour help here?
On the edit of the field you do your checks and include the current state of the issue as well...
By using the setError() function you can also throw a custom error message on that specific field and it won't allow them to save the issue.
This is something we often use to validate input regardless of the state to be sure the value has a certain format (often with a regular expression attached)
The problem we are having is we can't get the current status of the issue. We used what was in script runner documentation and script runner isn't recognizing the functions
This is from Script runner documentation
import com.atlassian.jira.component.ComponentAccessor
def workflow = ComponentAccessor.getWorkflowManager().getWorkflow(issue)
def wfd = workflow.getDescriptor()
def actionName = wfd.getAction(transientVars["actionId"] as int).getName() log.debug("Current action name: $actionName")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
we were trying to use these functions in script runner behaviors
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, Jira does not have any hooks on the "edit" action that you could plumb a script into.
The closest you can get would be a listener that picks up edits, checks what the users have put into it and changes it to something valid if they've made a mistake.
You'll still need validotrs on the transitions as well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The problem is we can't access the current state of the issue.
How do we access the current state of the issue using Script runner
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In a scripted listener, you would extract the issue from the event, and then get the status from the issue.
def issue = event.issue
def status = issue.getStatus().getName()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank You for your assistance.
What is the syntax for the function below in a listener?
By using the setError() function you can also throw a custom error message on that specific field and it won't allow them to save the issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
so using a listener won't work because we don't want to allow the user to save the issue.
Can you do this using behaviors?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
A listener can't stop an edit. It is running after the edit is complete.
You could do something with Behaviours on the edit screen, yes.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The problem I am trying to solve is users are changing the Value of the Delivery Field to 6.x in between state transitions. Can you throw an invalid exception error in Behaviors? How do you access the current state in Behaviors?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.