Hello,
I have found thanks to this thread : https://community.atlassian.com/t5/Jira-questions/How-to-execute-all-the-validators-defined-in-the-Workflow/qaq-p/892011
that I can use the "getValidators()" method to the the validators associated to a transition. However, it returns me the validator object (I assume), and I want the name and the description of what it does.
Example:
allStatuses.each { status ->
def relatedActions = eachWorkflowObject.getLinkedStep(status).getActions()
log.warn("For the status " + status.name + " the available transitions are: " + relatedActions)
relatedActions.each { it ->
def validators = it.getValidators()
log.warn("For the transition " + it + " the validators are: " + validators)
}
For the transition Close Issue (resolveissue) the validators are: [com.opensymphony.workflow.loader.ValidatorDescriptor@3e54be25]
That;s great, but I would love to get information like:
For the transition Close Issue (resolveissue) the validators are: resolution field is mandatory.
I tried with it.getValidators()*.name , or validators.name and it is blank.
What are the properties accepted by a validator, or the functions that can be used to get a readable description of the validator?
Thank you!
Hi!
Thanks for the very valid information within this post!
I would also need to iterate the "postfunctions", but using
transitionProperties.postfunctions.each
doesn't work.
Any idea how to get the postfunctions ?
Thanx in advance!
Regards, Hans
Just go to the help page and find information
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Etiennealexh ,
Not sure what help page information you are referring to. I searched the https://docs.atlassian.com/software/jira/docs , but couldn't find what I needed. If you know where that info would be, that would be helpful :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You were really close! You can use dot notation to get the information you're after.
From the script below, you can see that when we get to transitionProperties, i.e. the properties for each transition, we can access the validators for each by simply creating a closure using transitionProperties.validators.each
Within that closure, we see that we can further access the arguments of the validator by calling valid.properties.args. This results in output like so:
{nullallowed=true, permissionKey=ADMINISTER_PROJECTS, vars.key=<key>, class.name=com.atlassian.jira.workflow.validator.UserPermissionValidator}
Clearly the args would be different for every different kind of validator, but that should get you close.
import com.atlassian.jira.workflow.WorkflowManager
import com.atlassian.jira.component.ComponentAccessor
def workflowManager = ComponentAccessor.getComponent(WorkflowManager)
def wf = workflowManager.getWorkflow("<workflow name>")
//wf is the workflow itself
def statuses = wf.getLinkedStatusObjects()
//statuses are the statuses available to that workflow
statuses.each {
status ->
//For each status associated with the workflow
def relatedActions = wf.getLinkedStep(status).getActions()
//relatedActions is the set of actions (transitions) associated with each status
log.warn("For the status " + status.name + " the available transitions are: " + relatedActions)
relatedActions.each {
it ->
//For each related transition, we need the validators associated with the
def transitionProperties = it.properties
transitionProperties.validators.each {
valid ->
log.warn(valid.properties.args)
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi!
Thanks for the very valid information within this post!
I would also need to iterate the "postfunctions", but using
transitionProperties.postfunctions.each
doesn't work.
Any idea how to get the postfunctions ?
Thanx in advance!
Regards, Hans
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.