Automation get upcomming Issue status

Markus W_ BENES November 6, 2023

Is there a way to get the status an issue switches into? In the automation issue.status returns the status the issue actually has and not the status the issue will turn into.

2 answers

2 accepted

0 votes
Answer accepted
Vishal
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.
November 6, 2023

Hi @Markus W_ BENES ,

From your comment, it seems like you are running the automation before the actual transition & hence you are getting the previous status of the issue, in this case system would never know which status you are going to, so the automation is working correctly. (It cant predict the future :P)

You need to adjust your automation trigger such that it triggers after the actual transition to the status which you are expecting & then automation will then give you correct status.

Hope it clears your doubt.

Markus W_ BENES November 8, 2023

@Vishal thank you for your answer; helped me to understand my mistake. This is the code simplified iam using for now:

import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.StatusManager
import com.atlassian.jira.workflow.WorkflowManager

def toChangeIssue = "XX-XXXXX"

IssueManager im = ComponentAccessor.getIssueManager()
MutableIssue issue = im.getIssueObject(toChangeIssue)

def changeItem = ComponentAccessor.getChangeHistoryManager().getChangeItemsForField(issue,'status')?.last()
def transitionFrom= changeItem.getFromString()
def transitionTo = issue.getStatus()
Like # people like this
0 votes
Answer accepted
Wasim November 6, 2023

Hello @Markus W_ BENES ,

 

Welcome to Atlassian Community!!

Could you please explain the issue in details to understand properly..?

It will better to investigate the solution properly, If you attached the screenshot.

 

Regards,

Wasim Ansari

Markus W_ BENES November 6, 2023

@Wasim thank you for your question. If a user changes the status with a comment the automation event starts. my Problem is that the smart value issue.status returns only the status the ticket actually is an not the status it goes to. For example the ticket is in status "Waiting for Support". Customer changes the status to "Waitung for XYZ" and adds a comment. Event comment added starts but in Automation the status is still "Waiting for Support" and not "Waitung for XYZ". So the automation event goes before the status due the transition is updated.

Wasim November 6, 2023

Hi @Markus W_ BENES ,

 

Thank you for your response,

As I understood you'll try fetch the upcoming status using automation rule.

This isn't possible because the last transitioned status which is present into the changelog(jira issue history) is  "Waiting for Support" , the data is coming form your issue history it's can't predict your upcoming move.

 

Somehow if you are looking for your  expected result you have to fetch the value after issue got moved to the next status i.e; "Waiting for XYZ".

 you can use the following smart value to get the status related output:{{issue.status}} - Returns the issue's status

{{issue.status.name}} - Returns the issue's status

Please accept the answer if it will help you😊.

 

Regards,

Wasim

Like # people like this
Markus W_ BENES November 8, 2023

@Wasim Thanks this was the solution; helped me a lot :D

Like Wasim likes this

Suggest an answer

Log in or Sign up to answer