Problem in Post-Function Script

I have writte a post-functiion script which I am running with ScriptRunner. It clones an issue to a different project.

The script is triggered by the status change from "open" to "in progress". So far it works fine, the only strange problem is that in the list overview the status of the origin issue is displayed (even after browser refresh) with the status "open" while in the detail view the new status "in progress"is correctly displayed. The script as such works fine.

Anybody an idea what the reason could be?

Cheers,

Thomas

3 answers

1 accepted

Thanks Henning. Moving the posftfunction past the reindex solved the problem.

0 vote
Henning Tietgens Community Champion Feb 04, 2014

Your index has the wrong value for your origin issue. You have to make sure that you are using the provided issue object if you're making any changes to the origin issue. If you get a new issue object in the postfunction it's the old issue without the transition information. If you update the issue using this object you have an index problem.

Thanks for your explanation.

I am creating a new issue in a different project. For that I only invoke getterrs on the origin issue.

The only place where the origin issue might be changed is where I create the link which linking the origin and the new issue.

IssueLinkService.AddIssueLinkValidationResult linkValidationResult = issueLinkService.validateAddIssueLinks(currentUserObj, issue, linkType.id, Direction.OUT, targetIssueList, false);
    if (linkValidationResult.isValid()) {
        issueLinkService.addIssueLinks(currentUserObj,linkValidationResult);
    }

Could create that problem?

Btw, I cannot reproduce that problem on my local Jira 6.1.5. Unfortunately, I cannot upgrade the target Jira to 6.1.5 right now.

Any further idea?

Henning Tietgens Community Champion Feb 05, 2014

Yes, that could be the problem. In the JIRA source of version 6.0.7 the addIssueLinks() method calls issueManager.createIssueLink() only with the ID of the issue, which is then used to reindex a new issue object (which doesn't know about the changes).

Try to place your post function after the reindexing takes place could solve the problem.

Thanks for your explanation. I am creating a new issue in a different project For that I am only invoking getters on the origin issue.
The only place where the origin issue might be changed is the where I create the link which is linking the origin and the copied issue.

The code fragment is shown below:
IssueLinkService.AddIssueLinkValidationResult linkValidationResult = issueLinkService.validateAddIssueLinks(currentUserObj, issue, linkType.id, Direction.OUT, targetIssueList, false);
    if (linkValidationResult.isValid()) {
        issueLinkService.addIssueLinks(currentUserObj,linkValidationResult);
    }

Could that create that problem?
Btw, I cannot reproduce the problem on my local version 6.1.5. Unfornutately, I cannot upgrade the installlation where I have to run the script.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

56 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you