Hi guys, how are you doing.
I know this can be made using a condition, but, I'd like to do it using validator so a warning message can be shown.
That being said, here it goes:
I want to allow the issue transition only if the subtasks from that issue are all resolved or in a certain status.
How I'm trying to achieve this?
Workflow Validator > Script Runner Script
This is the Script:
def allSubtasks = get("/rest/api/2/search")
.issues as List<Map>
def allowClose = true
def subResolution = allSubtasks?.fields?.resolution
allowClose = false
Running this code (with some customizations, to get issue) on the Script Console, it returns correctly true, when all subtasks are with a resolution, and false when not.
But, when I add it to the Validator, seems to be always false, as it not allow me to perform the transition.
Thank you for your question.
I can confirm that validators in ScriptRunner for Jira Cloud use the Jira Expression Framework as described in the Atlassian documentation here which means you cannot write normal groovy code to write the validator expression.
We have created the Knowledge Base article located here which explains in more detail how validators work and how to check the syntax required to write them and you will be able to use this as a reference guide to help you create the validator that you require.
I can also confirm that we have collated some example validators here and one of the examples shows how to only allow an issue to be transitioned when all subtasks, are in the In Progress status and this will be a useful reference to help you to create the validator expression which you require.
I hope this information helps.
Yes , Scriptrunner jira cloud validator uses only jira expressions ,
Can u please help me to write Jira expression to check assignee is from specified group or not.I am trying following code :
['groupname' : 'administrators'].includes[issue.assignee.accountId]
Please help me.above expression does not return true still assignee is from administrators
I can confirm that validators inside of ScriptRunner for Jira Cloud are defined using the Jira Expression Framework as documented in the Atlassian API documentation page located here or in the documentation page located here which explains how to add in a new validator to your workflow.
We can confirm that when viewing the Jira Expression Framework API documentation page linked above you can navigate to the Context variables section which shows what variables are provided by this framework that can be used to create the expression. If you then click on one of the variables it will show all the properties that can be called on the variable for the expression such as for the issue variable as shown here.
Viewing the Context variables section of the Jira Expression Framework API documentation I can confirm that there is a user property as described here which has the groups property below it and this is what you will need to check against to check if a user is in a certain group.
Please note I cannot give you an exact condition as I do not have a condition to hand to achieve your requirement but you can use the information above to see how to check the Jira Expression Framework API documentation to see what properties can be used to create validators.
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event