Move Issue to specific Status when Custom Field Value is Selected on Transition Screen - JIRA DC

Digvijay Singh Gehlot
Contributor
July 16, 2024

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":

  • If option "In-Scope" is selected in custom field, the issue should move to different status as "For QA Review"
  • If option "Out of Scope" is selected, move the issue to status "Closed"

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

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Graham Twine
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 16, 2024

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')
}

 

 

Digvijay Singh Gehlot
Contributor
July 16, 2024

Hi @Graham Twine 

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

Graham Twine
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 17, 2024

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. 

TAGS
AUG Leaders

Atlassian Community Events