Scrip runner - Fast-track transition an issue not working properly

Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 4, 2014

Hi,

I am using the post function built in script "Fast-track transition an issue" but things don't seems to be working fine -

I haven't given any condition so it should work and the transition is taking place in the backgroud i.e. on UI I don't see the new status, it's still the name and icon of the old status but the transition buttons on the UI are in sync with the fact as if the transition has actually taken place.

Also I am trying to set comment and resolution but thats also not working -

issueInputParameters.setComment('Some comment')

issueInputParameters.setResolutionId('5')

This post function is on the create transition and I am using JIRA 5.2.11.

Thanks,

2 answers

1 accepted

1 vote
Answer accepted
Henning Tietgens
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.
March 5, 2014

Make sure it's the last postfunction in the list of postfunctions.

Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 5, 2014

Hi @henning, Thanks, putting it in the end worked.

But still I am not able to update the resolution or description, this is the code snippet I have added in the "Additional Code" Section

issueInputParameters.setResolutionId('5')

issueInputParameters.setDescription("I am a description");

Henning Tietgens
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.
March 5, 2014

Technically it has to be after the reindex because otherwise the reindex could take place after the fast track transition but with the issue data before the transition.

Try to add issueInputParameters.setSkipScreenCheck(true) to the additional code, maybe your transition screen doesn't contain description and resolution fields?

Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 5, 2014

Hi Henning,

First of all, thanks for sharing this fact regardin- if the fields aren't on screen then we have to use skipScreenCheck. I didn't know this fact as it isn't written on the script runner page where fast track transition info is give. But even after adding it I can't seems to update the description or the resolution - here's the code snippet

log.setLevel(org.apache.log4j.Level.DEBUG);
issue.setResolutionId('5');
issue.setDescription("I am a description");
issueInputParameters.setSkipScreenCheck(true);
log.debug(issue.getDescription()) ;

I can see in the logs the o/p of log.debug printed as "I am a description" but on the actual issue the description which I enter "test" while creating the issue still persists.

In the above code I tried with both

issue.setResolutionId('5'); and issueInputParameters.setResolutionId('5');

Both don't seems to work. Shall I re-index my test instance?

Jorge Rivero March 18, 2014

Tarun, did you get this to work?

I've build a listener that I can't seem to get to work. I'm getting odd behavior, such as: Issue shows Open with a resolution of Completed/Fixed (but the History of the issue shows that it changed from Open->Closed and from blank->Completed/Fixed. Reindexing does not make it work.

Also, if I withold the setResolutionId, I get a Closed issue with an Unresolved resolution.

Finally, I have tried doing 2 listeners: 1 to handle the Resolve Issue action and the other to handle the Close Issue action. This scenario does not work either.

All I want is the Issue with a certain summary (my condition) to, upon creation, set resolution to Completed/Fixed (1), status to Closed (6) and add a comment saying it was automatically fast-tracked.

Thanks.

Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 18, 2014

Hi Jorge,

I think the steps that your doing are fine, but with script runner I have faced an issue which is if you do to many things, then it might show odd behaviour as it's a open-source plugin and some of the features might not be well tested for all scenarios.

As you have specified -

All I want is the Issue with a certain summary (my condition) to, upon creation, set resolution to Completed/Fixed (1), status to Closed (6) and add a comment saying it was automatically fast-tracked

I would suggest you to write a simple script in the post function to do all of the above instead of relying on fast tracking an issue. The Mutable issue API contains everything for setting commet / resolution and for the status part only and only use workflowutil other-wise data might get corrupted see here -

https://answers.atlassian.com/questions/116537/proper-way-to-change-issue-status-in-code

Mutableissue - https://developer.atlassian.com/static/javadoc/jira/5.0.5/reference/com/atlassian/jira/issue/MutableIssue.html

right way to perform issueoperations - IssueService-

https://developer.atlassian.com/display/JIRADEV/Performing+Issue+Operations

Jorge Rivero March 18, 2014

Thank you for the guidance Tarun. It looks that I will have to do exactly as you suggested.

Thanks again!

0 votes
Tian Lixin April 16, 2014

Hi, Tarun,

I tried to do the same thing: adding a fast-track transition post function for transition from Create to New, leaving the condition empty so it's always true, and set action to 'Create(1)', add addtional code setComment. But nothing happened. I've already moved it to the end of all post functions. Do you know why?

Suggest an answer

Log in or Sign up to answer