Auto transition issue

Sir Be April 15, 2014

I want to auto-transition all created issues of a certain issue-type in JIRA 4.2.

I've added a script listener (build in scripts: Fast-track transition an issue).

Event: issue-created.

Condition: issue.type == 'aa'

Action: Some(X)

Additional code: issueInputParameters.setComment('Auto-transition')

But somehow it doesn't seem to work.

When i create an issue: Fire a Issue Created event that can be processed by the listeners.

Even when no condition is added, it doesn't work.

Thanks.


EDIT:
What's the syntax for the issue type?
issue.issuetype?.name == 'aa' ?

4 answers

1 accepted

0 votes
Answer accepted
Sir Be April 17, 2014

according to https://answers.atlassian.com/questions/24245/why-is-jira-saying-that-a-perfectly-valid-transition-for-my-issue-is-invalid

There's a problem with the issue creation.

Henceforth i've abandoned the auto-transition path.

The user has to do now the 'accept' state manually.

1 vote
Tansu Kahyaoglu April 15, 2014

Are you sure that status Open has Action: Some(X)

Sir Be April 15, 2014

My workflow is:
create -> open -(some(X))->resolved (resolution 1)
| ->open --(some(Y))->resolved (resolution 2)

So yes.

I want the autoTransition of open -> resolved (resolution 1) when the issue type is aa.

Tansu Kahyaoglu April 15, 2014

Do you have anything on the log files regarding to error?

I believe it's a required field (probably resolution) or validator creating problem.

BTW correct syntax for condition is

issue.getIssueType().name.equals('Bug')

I tested it on JIRA 4.4, it should be the same JIRA 4.2

Sir Be April 15, 2014

Ahha
I couldn't find the correct syntax.



Added also:

issueInputParameters.setComment('Auto-transition')

issue.setResolutionId('6')

as Additional code


I now do get an error:

Error creating issue: Can't transition workflow instance #10301. Current state is 4, requested state is 1

2014-04-16 16:26:58,595 http-8080-4 ERROR admin 986x166x1 1dbb30k 0:0:0:0:0:0:0:1 /secure/CreateIssueDetails.jspa [atlassian.jira.workflow.SimpleWorkflowManager] Error occurred while creating issue.

com.opensymphony.workflow.InvalidEntryStateException: Can't transition workflow instance #10301. Current state is 4, requested state is 1

ErrorLogAutoTransition.txt

Does the issue have to be first in the 'open' status?
Cause i'm now directly (trying to) transition it from create to resolved.

Tansu Kahyaoglu April 15, 2014

Ok here how I did it:

Go Administration-> Script Runner -> Script Listeners and select Fast Track Transition. Configure it based on my config below. Don't add any additional validation or post function to Create Transition. Then go to your Some Action(X) and put post function Update Issue Field -> Resolution. Then publish your workflow. It must work :)

PS: Better you should go to Open first then Fast Track Transition your Action X

Sir Be April 15, 2014

put post function Update Issue Field -> Resolution = issue.setResolutionId('6') ?

When the issue gets created: last post function: Fire a Issue Created event that can be processed by the listeners. So normally it should be to open status, but it should be resolved with resolution = 6.

Technically it should work, but it doesn't...

Thank you for your help so far :)

Tansu Kahyaoglu April 15, 2014

You're welcome and sorry for my unclear answer. You should clear all post functions from Create. So issue should be created normally. Then go to transition some(x) in your workflow where some(x) is the transition of

open -(some(X))->resolved (resolution 1)

add the "update issue field" post function to some(x). This not something you do it with script.

So logic basically is, create issue normally and let it go to Open status. Then using script listener, trigger some(x) action. When some(x) triggered it updates issue to set resolution. Config for the script runner listener is in my previous comment.

Sir Be April 16, 2014

NP

I make my listener like your prt scr.

The Resolution of the issue will be set to 6.
Edit | Move Down | Delete

(Does it mather where this line is located? 1st or last function?)

Create issue has no extra post functions.

issue creates normally and stays in 'open' :(

ERROR in log:

2014-04-17 10:07:15,275 http-8080-1 ERROR test2 607x817x1 1ohlw0 0:0:0:0:0:0:0:1 /secure/CreateIssueDetails.jspa [groovy.canned.utils.WorkflowUtils] Errors: {}

Error Messages: [It seems that you have tried to perform a workflow operation (Accept) that is not valid for the current state of this issue (ABSENCE-56). The likely cause is that somebody has changed the issue recently, please look at the issue history for details.]

2014-04-17 10:07:15,275 http-8080-1 ERROR test2 607x817x1 1ohlw0 0:0:0:0:0:0:0:1 /secure/CreateIssueDetails.jspa [groovy.canned.utils.WorkflowUtils] Not attmpting transition

0 votes
Andrew
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 9, 2014

On a related topic, if you are using JIRA Server 6.3.3 (or later) or JIRA Cloud plus at least one of the following:

  • Stash 3.2.0 (or later)
  • FishEye/Crucible 3.5.2 (or later)
  • GitHub Enterprise 11.10.290 (or later)
  • Bitbucket
  • GitHub

you can configure triggers for your workflow that will automatically transition issues when events occur in your development tools (e.g. commit created).

See https://confluence.atlassian.com/display/JIRA/Configuring+workflow+triggers for details.

0 votes
Paresh Gandhi
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.
April 15, 2014

issue.issueTypeObject.name == 'aa'

you are doing it in correct way. please try above code.

Sir Be April 16, 2014

No signature of method: com.atlassian.jira.issue.IssueImpl.issueTypeObject() is applicable for argument types: () values: []

Possible solutions: getIssueTypeObject()

tried issueTypeObject.name

EDIT:

issue.getIssueTypeObject() doesn't work

issue.getIssueTypeObject().getName() niether

Paresh Gandhi
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.
April 16, 2014

I'm using issue.issueTypeObject.name == 'aa' and it is working perfectly fine.

Paresh Gandhi
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.
April 16, 2014

refer to screenshot

Sir Be April 17, 2014

Printed these 4 out, give all the same result

issue.issueType.name

issue.getIssueType().name

issue.issueTypeObject.name

issue.getIssueTypeObject().getName()

---------------------

Error Messages: [It seems that you have tried to perform a workflow operation (Accept) that is not valid for the current state of this issue (ABSENCE-89). The likely cause is that somebody has changed the issue recently, please look at the issue history for details.]

Is this possible cause the accept state may only be done by a special group.

A group in which the normal user (i have been testing with) isn't included.

---------------------

So I wanted to test it with the admin (who is in that special group).

Error creating issue: Can't transition workflow instance #10415. Current state is 4, requested state is 1

if the current state is equal to the id of the status, then 4 is equal to reopend.

However I was creating an issue and reopen doesn't occur in my workflow.

--------------------

When i change the action 'accept' to 'edit' (what is also possible in the open status), it works.

------------------

according to https://answers.atlassian.com/questions/24245/why-is-jira-saying-that-a-perfectly-valid-transition-for-my-issue-is-invalid

There's a problem with the issue creation.

Henceforth i've abandoned the auto-transition path.

The user has to do now the 'accept' state manually.

Suggest an answer

Log in or Sign up to answer