Hi Community,
I want to move the issue to a specific workflow status automatically when a user selects a value in custom single select (single choice) field, present on transition screen.
For example:
When issue moves from status "In Progress" to "Closed", open the transition screen "Need Approval" and select a value in custom field "Select Scope" (single select) - either option: "In-Scope" or "Out of Scope":
Please guide how I can achieve the above use-case, using scriptrunner, JMWE app, JIRA automation or Post Functions.
It would be a great help.
Thank you
Hello @Digvijay Singh Gehlot ,
In a post function check if the value is present and transition the issue
There is a guide in Adaptavast's documentation on how to do this.
NOTE: The below is using the transition and not the status.
The transition can also opt to ignore conditions, validators and permissions.
It can also add things to the issue such as comments.
I recommend you have a look at the documentation linked above
def scope = issue.getCustomFieldValue('Select Scope')
if ('In Scope' == scope) {
issue.transition('Start QA Review')
} else if ('Out of Scope' == scope) {
issue.transition('Close')
}
Thank you for your message and for sharing the necessary document.
However, after implementing the suggested, I am getting error message with keyword: "issue" in the script.
It says "[Static type checking] - The variable [issue] is undeclared"
I also tried to execute the code with issue.status but facing the same error message as below:
def scope = issue.getCustomFieldValue('Select Scope')
if ('In Scope' == scope) {
issue.status('QA Review')
} else if ('Out of Scope' == scope) {
issue.status('Closed')
}
And may you also help, which scriptrunner Post-Function should I add to execute the above script (using issue.status)?
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
One cannot just assign a new status to an issue in the way you have done it.
issue.status('Some new Status')
Transitions are used to move issues about.
When an issue transitions it needs to pass through some gates.
Conditions - Can it even move. Before the fact
Validations - It can move but some criteria is checked. During the fact.
With the above in mind, use the transition and NOT the status.
I really recommend you read the documentation on this it is quite informative and will guide you well.
https://docs.adaptavist.com/sr4js/latest/hapi/transition-issues
With regards to static type checking. These are not errors per say. The context in which the groovy script is processed is important. The Script Editor has no context.
Open a workflow script in the Script Editor and you will get type checking errors.
Create the same script as an inline script in a workflow and there may be no type checking errors
It is possible to write code that shows errors, but it is valid and executes fine.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.